Constant

See also: Reference – Constant items

A constant is an item that is const-evaluated at compile time and inlined at every usage site. Unlike static variables, constants don't have a fixed memory location; therefore, references to the same constant can point to different memory locations.

Constants must be explicitly typed and have a lifetime:

Since constants are evaluated and inlined at compile time, the above is semantically equivalent to

Constants can have a destructor, which is run when the constant goes out of scope.

It is possible to create unnamed constants, which use the underscore instead of a name: