Expand description
Derive macros for tinystate.
This crate provides procedural macros to automatically implement the States and Events
traits for enum types, eliminating boilerplate code.
§Usage
Enable the derive feature in your Cargo.toml:
[dependencies]
tinystate = { version = "0.1", features = ["derive"] }Then derive the traits on your enums:
ⓘ
use tinystate::{States, Events};
#[derive(States)]
enum TrafficLight {
Red,
Yellow,
Green,
}
#[derive(Events)]
enum TrafficEvent {
Timer,
Emergency,
}§Requirements
- Both macros only work on enums with unit variants (no fields)
- The first variant of a
Statesenum becomes the default state