rust命名规范
原文:Naming - Rust API Guidelines (rust-lang.github.io)
snake_case:蛇形命名法,使用下划线连接小写字母CamelCase:驼峰命名法,根据首字母大小写分为大小驼峰,rust里使用大驼峰UpperCamelCase:第一个词的首字母,以及后面每个词的首字母都大写lowerCamelCase:第一个词的首字母小写,后面每个词的首字母大写
| 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 , usually single uppercase letter: UpperCamelCase``T |
| Lifetimes | short , usually a single letter: , , lowercase``'a``'de``'src |
| Features | unclear but see C-FEATURE |