Types, Structs, and Enums
Flint includes primitive numeric and boolean types, user-defined structs, and enums used as tagged unions.
Structs
Structs group fields together:
struct Sensor {
pin: u8,
offset: f32,
}
Enums
Enums represent one of several variants:
enum Command {
Read(pin: u8),
Write(pin: u8, value: bool),
Reset,
}
This form is especially important for protocol parsing, driver state, and result-oriented programming.
Pattern Matching
Enums become much more useful together with match:
match cmd {
Command.Read(pin) => { return ok(pin) }
Command.Write(pin, value) => { return ok(pin) }
Command.Reset => { return ok(0) }
}
Flint uses tagged unions as a normal language tool, not as a niche feature.