Rust has a variety of familiar types:
bool
for representing true/falseu8
u16
u32
u64
u128
for representing nonnegative whole numbersi8
i16
i32
i64
i128
for representing whole numbersusize
isize
for representing indexes
and sizes of things in memoryf32
f64
char
for representing a single Unicode character(value, value, ...)
for passing fixed sequences of values on the stack[value, value, ...]
a collection of similar elements with fixed length known at compile timestr
(string slice) - text with a length known at runtimeText might be more complex than you are used to in other languages; since Rust is a system programming language, it cares about memory issues you might not be used to. We will be going into this in detail later.
Numeric types can be explicitly specified by appending the type to the end of the number (e.g. 13u32
, 2u8
).