Primitives

Contents

Primitives#

Type

Notes

i8 i16 i32 i64 i128 isize

signed integers; isize is the pointer-width signed.

u8 u16 u32 u64 u128 usize

unsigned; usize is the pointer-width unsigned (used for indices and lengths).

f32 f64

IEEE 754. f64 is the default.

bool

true / false. Not an integer; cannot coerce.

char

4-byte Unicode code point. Not a byte.

()

unit; one value, also (). Used as “no return value”.

!

never; the type of expressions that diverge (panic!, return, continue).

Integer literal suffixes pin the type.

let n = 42_u32;
let big = 1_000_000_i64;

References#

  • Casting for as conversions between numeric types.

  • Operators for arithmetic and bitwise operators.