Type

A type is a classification of values. Values of the same type have a similar meaning and purpose, and support the same operations. Values of different types can have the same memory representation – for example, both  and   can be represented by a zero, but because they are different types, the zero has a different meaning.

In Rust, types are enforced at compile time to prevent logic errors. However, since memory safety invariants are encoded in the type system, it also prevents memory safety bugs.

Types in Rust can be divided into:


 * Primitive types
 * Structs
 * Enums
 * Unions
 * Opaque types

Types can be generic. Generic types are sometimes called type constructors. For example,  is generic over. By substituting  with a type, new types such as   or   can be created.

Traits aren't types, but they categorize types with certain properties or functionality.