Rust datatypes

From wikinotes
Revision as of 22:32, 29 August 2021 by Will (talk | contribs) (→‎Integers)

Primitives

Text

char

char

Numbers

implied type let var = 12;
assigned type let var: i8 = 12;
type suffix let var = 12i8;

Integers

  • signed integers are positive, and use all available bits
  • unsigned integers range is split in two, can be positive/negative
  • use radix to calculate max size that can be accomodated with b bits
// signed integers, by bit-size
i8
i16
i32
i64
i128
isize

// unsigned integers, by bit-size
u8
u16
u36
u64
u128
usize

Floating Point

Boolean

true
false

Collections

tuples

arrays