参考:https://rust-lang.github.io/api-guidelines/naming.html
| Item | Convention | | —- | —- |
|
Crates
| unclear,大小写不敏感、- 和 _ 被认为是相同的
|
|
Modules
| snake_case
|
|
Types
| UpperCamelCase
|
|
Traits
| UpperCamelCase
|
|
Enum variants
| UpperCamelCase
|
|
Functions
| snake_case
|
|
Methods
| snake_case
|
|
General constructors
| new or with_more_details
|
|
Conversion constructors
| from_some_other_type
|
|
Macros
| snake_case!
|
|
Local variables
| snake_case
|
|
Statics
| SCREAMING_SNAKE_CASE
|
|
Constants
| SCREAMING_SNAKE_CASE
|
|
Type parameters
| concise UpperCamelCase, usually single uppercase letter: T
|
|
Lifetimes
| short lowercase, usually a single letter: 'a, 'de, 'src
|
| Features | unclear but see C-FEATURE |
In UpperCamelCase, acronyms and contractions of compound words count as one word: use Uuid rather than UUID, Usize rather than USize or Stdin rather than StdIn.
In snake_case, acronyms and contractions are lower-cased: is_xid_start.
