Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces around = in attributes #82

Closed
s3rvac opened this issue Apr 8, 2017 · 3 comments
Closed

Spaces around = in attributes #82

s3rvac opened this issue Apr 8, 2017 · 3 comments
Labels

Comments

@s3rvac
Copy link

s3rvac commented Apr 8, 2017

Should we put spaces around the equal sign (=) in attributes? For example, should we write

#![recursion_limit="1024"]

or

#![recursion_limit = "1024"]

?

Notes:

  • rustfmt does not seem to care about this. It keeps whatever amount of whitespace I use. However, when I write let x=1;, it corrects that to let x = 1;.
  • The Rust Reference uses both styles, even inside of a single code block:
#![crate_type = "lib"]

// ...

#[cfg(target_os="linux")]
  • There is no example code for this in the examples part of this repo.
  • I was unable to find this piece of information in the Attributes section of the guide. Does the following rule also apply to attributes?

Do include spaces around binary ops (i.e., x + 1, not x+1) (including =).

If so, then maybe we should add this to the Attributes section of the guide (including an example) to prevent confusion and add a formatting rule to rustfmt.

@nrc
Copy link
Member

nrc commented May 9, 2017

I agree we do need to decide this. I tend to write it without spaces myself, however, given that everywhere else = is used, it gets spaces I think we probably ought to do that here too.

@Boscop
Copy link

Boscop commented May 9, 2017

I also think there should be spaces. I used to write it without spaces (because I read it that way in example code) but now I always write the spaces for consistency.

@ivandardi
Copy link

I like it without spaces. Python does it with function default arguments, and I'm really glad they do, otherwise function declarations would be really long. Likewise, if we opt for no spaces around = in attributes, we can compress the code a little bit more, and I really wouldn't like having to split an attribute over multiple lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants