Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/therustmonk/taker
Option-like taking for everything (Rust)
https://github.com/therustmonk/taker
Last synced: 17 days ago
JSON representation
Option-like taking for everything (Rust)
- Host: GitHub
- URL: https://github.com/therustmonk/taker
- Owner: therustmonk
- Created: 2021-03-23T17:58:13.000Z (almost 4 years ago)
- Default Branch: trunk
- Last Pushed: 2021-03-23T18:02:54.000Z (almost 4 years ago)
- Last Synced: 2025-01-02T21:12:46.865Z (21 days ago)
- Language: Rust
- Size: 1000 Bytes
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# taker
Make FSM on any that that has `Default` implementation.
How to use it:
```rust
#[derive(Debug, PartialEq, Eq)]
enum Fsm {
State1,
State2,
Transition,
}impl Default for Fsm {
fn default() -> Self {
Self::Transition
}
}let mut fsm = Fsm::State1;
match fsm.take() {
Fsm::State1 => {
fsm.set(Fsm::State2);
}
Fsm::State2 => {
fsm.set(Fsm::State1);
}
_ => {
panic!("Stucked in transition state...");
}
}
```