-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Finalizing more naming conventions #430
Conversation
d170748
to
f925a6f
Compare
| General constructors | `new` or `new_with_more_details` | | ||
| Conversion constructors | `from_some_other_type` | | ||
| Local variables | `snake_case` | | ||
| Static variables | `SCREAMING_SNAKE_CASE` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constants as well, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should consider CamelCase
for constants, since SCREAMING_SNAKE_CASE
is extremely abrasive to look at and it more clearly demonstrates the difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that there are precedents in both directions here, and I'm not sure it's clear that we should draw a distinction between these two kinds of variables.
Looking around, we've got:
I'll also point out that "SCREAMING_SNAKE_CASE" is abrasive probably because it has the word "screaming" in all caps. Something like MAX_WIDTH
vs MaxWidth
seems less abrasive to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to use enums to represent keys in a termbox-like console input library, but it turns out that Ctrl-I and Tab keys map to the same escape sequence so I'll have to use CTRL_I
and TAB
instead of CtrlI
and Tab
now if I want to use it in a match
:(
I think |
Yup. I agree with @glaebhoerl on this. Either that or make variants screaming, but I don't think anyone wants that! |
I agree with @glaebhoerl in that constants and enum variants should share the same I think it's fair though that static variables stand out (using |
That's the other idea I was going to float... perhaps it might make sense to distinguish mutable |
This discusses acronyms in camel case but not snake case: e.g. |
Especially big +1 for |
Just to leave my two cents on the topic of statics. I'm all for "screaming case" (Caps) for constants, but for interior mutable data (StaticMutex) using snake case would be preferable. [Similar to @glaebhoerl's comment] |
(That's actually the reverse of my comment.) |
Isn't the convention not |
Good catch! This was leftover from the original wiki that I started with. I will update. |
Accepted. Discussion. Tracking. |
Accidentally rebased this instead of merged. |
This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all `unwrap` methods are retained as `#[deprecated]` for the near future. To update code rename `unwrap` method calls to `into_inner`. [rfc]: rust-lang/rfcs#430 [breaking-change] Closes rust-lang#13159 cc rust-lang#19091
This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all `unwrap` methods are retained as `#[deprecated]` for the near future. To update code rename `unwrap` method calls to `into_inner`. [rfc]: rust-lang/rfcs#430 [breaking-change] Closes rust-lang#13159 cc rust-lang#19091
This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all `unwrap` methods are retained as `#[deprecated]` for the near future. To update code rename `unwrap` method calls to `into_inner`. [rfc]: rust-lang/rfcs#430 [breaking-change] cc #19091
Apply conventions described in [Rust RFC 430][rfc] where `unwrap` is reserved for panicing methods. [rfc]: rust-lang/rfcs#430
This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all `unwrap` methods are retained as `#[deprecated]` for the near future. To update code rename `unwrap` method calls to `into_inner`. [rfc]: rust-lang/rfcs#430 [breaking-change] Closes #13159 cc #19091
Just came here to point out that ThisNamingConvention is more accurately referred to as Pascal Case. In the documentation you refer to it as Camel Case, which more commonly follows thisPattern. |
Hey, just came here to state the same thing as @Pyython. You refer to |
By docs, do you mean the RFC? Ideally, we'd have these docs living somewhere else and update there, but I'm not sure if they do. We don't generally modify the text of RFCs heavily after they're landed, prefering to keep more stable docs up to date. |
This conventions RFC tweaks and finalizes a few long-running de facto
conventions, including capitalization/underscores, and the role of the
unwrap
method.See this RFC for a competing proposal for
unwrap
.Rendered
Note: Though marked as closed, this RFC was in fact accepted.