Tag: [[reference]]

  • Basic Enumerations

    Basic Enumerations

    An enumeration, or enum in Rust, is a way to declare a custom data type that describes, or enumerates, possible variations of a certain category. In the example below, the data type is named Language, and it serves as the category for which all the named items within are a part. English, Spanish, etc. are all a member of the Language enumeration. Enumerations…

  • Constants

    Constants

    The const keyword is similar to the let keyword: it allows the creation of an immutable variable. Constants can never be mutable, and they must always be set to a constant expression, i.e., something that has a definite value and that is not the result of a runtime calculation. Note: the f32 and u32 are type declarations for a 32-bit floating point and 32-bit…

  • Mutable Variables

    Mutable Variables

    Making a variable mutable is simple with the mut keyword. Mutability means that the value of a variable can be overwritten. See the example below: