Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Data Types

Inference is a statically typed language — every value and variable must have a known type at compile time.

Integer Types

Inference supports both signed and unsigned integer types:

Length (in bits)SignedUnsigned
8i8u8
16i16u16
32i32u32
64i64u64
let small: i8 = 127;
let byte: u8 = 255;
let number: i32 = 42;
let big: i64 = 1000000;
let positive: u32 = 0;

i32 is the most common integer type and maps directly to a 32-bit integer in WebAssembly.

Boolean Type

let flag: bool = true;
let done: bool = false;

Array Type

Fixed-size arrays are written as [T; N], where T is the element type and N is a compile-time constant:

let numbers: [i32; 3] = [1, 2, 3];

See Arrays for full coverage.

Struct Type

User-defined types with named fields:

struct Point {
    x: i32;
    y: i32;
}

let p: Point = Point { x: 10, y: 20 };

Structs support methods via impl blocks — see Functions for details.

Enum Type

A type with a fixed set of named variants:

enum Color { Red, Green, Blue }

let c: Color = Color::Red;

See Enums for full coverage.

Floating-Point Types

Inference does not support floating-point types. It uses integer arithmetic to ensure determinism and precision in computations.