1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use typestate_proc_macro::typestate;
#[typestate(enumerate)]
mod traffic_light {
#[automaton]
pub struct TrafficLight {
pub cycles: u64,
}
#[state]
pub struct Green;
#[state]
pub struct Yellow;
#[state]
pub struct Red;
// #[transition]
pub trait Green {
fn to_yellow(self) -> Yellow;
}
pub trait Yellow {
fn to_red(self) -> Red;
}
pub trait Red {
fn to_green(self) -> Green;
fn turn_on() -> Red;
fn turn_off(self);
fn to_either(self) -> Either;
}
pub enum A {}
pub enum Either {
Yellow,
Red,
A
}
}
fn main() {}