Let's look at the basic types provided by the language, such as integers, floats, Booleans, and characters.
The following integer types are available in Rust:
Unsigned | Signed |
---|---|
|
|
|
|
|
|
|
|
|
|
The u
means unsigned, while the i
means signed, and the number following it is the number of bits. For instance, a number of the u8
type can be between 0 and 255, inclusive. And a number of the i16
type can be between -32768 and 32767, inclusive. The size variants are the pointer-sized integer types: usize
and isize
are 64-bit on a 64-bit CPU. The default integer type is i32
, which means that this type will be used by the type inference when it cannot choose a more specific type.