Custom Data Types

Zig allows you to define sets of fields as structs and sets of types/variants or values as enums.

Structs

// types.zig

const Cartesian = struct {
    x: f32,
    y: f32,
}

aconst Polar = struct {
    angle: f32,
    distance: f32,
}

Enums

// types.zig

const Target = enum {
    Map: Cartesian,
    Radar: Polar,
}

Data Structures

results matching ""

    No results matching ""