| Crates.io | statemachine-macro |
| lib.rs | statemachine-macro |
| version | 0.1.1 |
| created_at | 2020-09-09 19:51:52.991863+00 |
| updated_at | 2020-09-09 22:23:50.585089+00 |
| description | Provides the statemachine!() macro for easily creating statemachines. |
| homepage | |
| repository | https://gitlab.com/FloorIsJava/statemachine-macro |
| max_upload_size | |
| id | 286833 |
| size | 36,142 |
A Rust crate providing a macro to easily create state machines. Documentation is available on docs.rs.
Add this to your Cargo.toml:
[dependencies]
statemachine-macro = "0.1"
use statemachine_macro::*;
statemachine! {
struct Foo;
enum FooState consumes [char] from Start accepts [NonEmpty];
Start => {
char match _ => NonEmpty
},
NonEmpty => {
_ => NonEmpty
}
}
fn main() {
let mut foo: Foo = statemachine_new!(Foo{});
assert!(!foo.is_accepting());
foo.consume('a');
assert!(foo.is_accepting());
foo.consume('b');
assert!(foo.is_accepting());
foo.consume('c');
assert!(foo.is_accepting());
}
This crate is published under the terms of the MIT license. See the LICENSE file for details.