Primitive Data Types in Detail

Updated

October 31, 2026

Primitive Data Types in Detail

Rust is statically and strongly typed with full type inference.

Scalar Types

  1. Integers:
    • Signed: i8, i16, i32, i64, i128, isize (pointer width)
    • Unsigned: u8, u16, u32, u64, u128, usize (pointer width, indexing)
  2. Floating-point: f32, f64 (IEEE 754-2008)
  3. Boolean: bool (true or false, 1 byte representation)
  4. Character: char (4-byte Unicode scalar value)
fn main() {
    let count: usize = 42;
    let temperature: f64 = 98.6;
    let is_active: bool = true;
    let emoji: char = '🦀';

    println!("Scalar values: {}, {}, {}, {}", count, temperature, is_active, emoji);
}