We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fn accepts_…(&self) -> bool
Given a state-machine like traffic_light.rs, i.e. …
transitions!(Traffic, [ (Green, Advance) => Orange, (Orange, Advance) => Red, (Red, Advance) => Green, (Green, PassCar) => [Green, Orange] ] );
… it would be nice if machine would auto-generate helper methods on the outer enum type for checking input acceptance …
impl Traffic { pub fn accepts_advance(&self) -> bool { match self { Traffic::Green(_) => true, Traffic::Orange(_) => true, Traffic::Red(_) => true, _ => false, } } pub fn accepts_pass_car(&self) -> bool { match self { Traffic::Green(_) => true, _ => false, } } }
… instead of requiring one to implement them manually, as shown in the example (fn can_pass(&self) -> bool).
fn can_pass(&self) -> bool
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Given a state-machine like traffic_light.rs, i.e. …
… it would be nice if machine would auto-generate helper methods on the outer enum type for checking input acceptance …
… instead of requiring one to implement them manually, as shown in the example (
fn can_pass(&self) -> bool
).The text was updated successfully, but these errors were encountered: