taker

Crates.iotaker
lib.rstaker
version0.1.0
sourcesrc
created_at2021-03-23 18:04:29.681687
updated_at2021-03-23 18:04:29.681687
descriptionOption-like taking for everyting with a default value.
homepage
repositoryhttps://github.com/DenisKolodin/taker
max_upload_size
id372666
size2,878
Denis Kolodin (therustmonk)

documentation

README

taker

Make FSM on any that that has Default implementation.

How to use it:

#[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...");
    }
}
Commit count: 2

cargo fmt