Rust Naming Conventions: The Official Style Guide

4 min read

Rust enforces naming conventions at the compiler level — using the wrong case triggers a warning.

Convention Table

ItemConventionExample
Variablessnake_caselet user_name = ...
Functionssnake_casefn get_user()
StructsPascalCasestruct UserAccount
EnumsPascalCaseenum Color { Red, Blue }
TraitsPascalCasetrait Serialize
ConstantsSCREAMING_SNAKEconst MAX_SIZE: u32
Modulessnake_casemod user_auth
Crate namessnake_caseserde_json
Type parametersSingle uppercaseT, K, V
LifetimesShort lowercase'a, 'ctx

Convert

snake_case, PascalCase, or CONSTANT_CASE. Hub.