Type¶
A type is a description of a set of values and a set of operations on those values.
A value is an instance of a specified type; for example 42 is an instance of type i32.
User-defined types¶
You can define your own types using the type declaration syntax.
Predefined types¶
Some types are not a set of values of other types, but values in themselves.
| Category | Types |
|---|---|
| Signed integers | i8, i16, i32, i64, i128, isize |
| Unsigned integers | u8, u16, u32, u64, u128, usize |
| Boolean type | bool |
| Float-point | f16, f32, f64 |
Most of the predefined types are:
- Contain a number — this number describes how many bits the type value takes in memory.
- Lowercase — they are all keywords, and just a shortcut to their full name.
You probably thought that user-defined and predefined are very separate categories of types.
This is not the case.
In reality predefined type i32 corresponds to user-defined type SInteger32 in the standard library.
The key difference is that predefined types are more controlled by the compiler than by the user.
TODO
Better make separate folder with type, interface, predefined types, enums, conversions.