RustBrock/Constants.md

368 B

Constants

  • Can be declared anywhere,
  • The convention to use all caps in a constant's name
  • Needs const keyword
  • Not always evaluated at compile time (there are rules for this but too complex to know everything)
  • Variables can only be assigned once (needs mut to assign more than once (need to be same type))
const SECONDS_PER_HOUR: i32 = 60 * 60;