Rust has attributes[1] at function-level but (1) the compilation could
be faster if they were at file-level, and (2) the project would be more
homogeneous and clean.

+ Instead of to have the attribute "#[test]" for a function, those tests
functions could be into a file with the name finished in "_test"
(foo_test.rs) indicating that there are unit tests. On this case, we
would not need an attribute.

+ Instead of to have conditionally-compiled modules at function level,
that code could be into a file finished in the system name
(foo_linux.rs), and/or use attributes at file level. See how Go solved
this problem, in Build constraints[2].

+ Instead of to have an attribute for the documentation, the parser
could get the comment on top of the function to get its documentation.

Now:

  // A documentation attribute
  #[doc = "Add two numbers together."]
  fn add(x: int, y: int) { x + y }

Proposal:

  // add adds two numbers together."
  fn add(x: int, y: int) { x + y }


[1]: http://dl.rust-lang.org/doc/0.4/rust.html#attributes
[2]: http://golang.org/pkg/go/build/
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to