coding-guidelines
coding-guidelines copied to clipboard
Add variable naming section on expressing unit of the type
If a type does not include the unit of the value, the variable name has to. Otherwise it becomes hard to know what is what.
// The type expresses the unit. Best solution.
let interval: Duration = Duration::from_millis(1001);
// The variable expresses the unit. Good solution for when the type can't or should not express the unit.
let interval_ms: u64 = 1001;
// Neither expresses the unit. Very hard to read, understand and properly use:
let interval: u64 = 1001;