One other thing which I have noticed.  The suggested form for a function declaration is difficult to maintain in light of refactorings and in particular search-and-replace commands.  That is, if you place each argument on a separate line and line that line up with the opening parenthesis, as suggested:

     fn foo(p1: P1,
            p2: P2) {
     }

Then if I rename `foo()` to `foo_bar()` via search-and-replace, I wind up with the following:

     fn foo_bar(p1: P1,
            p2: P2) {
     }
 

I find this happens...semi-regularly and it's annoying.

Perhaps it would be better to format functions as follows:

     fn foo(
         p1: P1,

         p2: P2)
     {
         code
     }

or as follows:

     fn foo(
             p1: P1,

             p2: P2) {
         code // double indent distinguish parameters from code

     }

Any of those options neatly avoids this problem, and also scales better to long type names.


Niko
April 10, 2013 6:57 PM
There have been a few mentions recently about writing up the Rust coding standards. Several of us sat in a room and tried to identify and agree on some that we thought were important. I've pasted the resulting notes into the wiki:

https://github.com/mozilla/rust/wiki/Note-style-guide

These are very, very rough but cover a number of topics. Comments and suggestions are welcome. These need to be cleaned up into readable prose, with decent examples, and moved from the 'Notes' section of the wiki to the 'Docs' section where users will find them. Help is definitely appreciated.

-Brian
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to