In Rust, `const` declares an unchanging value evaluated at compile time. Each constant needs an explicit type annotation. section 2.3
A const is useful when a value is known before the program runs:
- Constants are conventionally written in uppercase and often declared outside `main` so they can be accessed throughout the program. section 2.3
- A const can hold a set of allowed input characters, which code can check against. section 14.3.1
const NUMBER_OF_MONTHS: u32 = 12;
fn print_months() { #1
println!("Number of months in the year: {NUMBER_OF_MONTHS}");
}
fn main() {
print_months();
}
This example declares a typed constant outside `main` and reads it inside another function. section 2.3







