diff options
Diffstat (limited to 'examples/example-implicit-dispatcher/src/main.rs')
| -rw-r--r-- | examples/example-implicit-dispatcher/src/main.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/example-implicit-dispatcher/src/main.rs b/examples/example-implicit-dispatcher/src/main.rs new file mode 100644 index 0000000..3dc7f83 --- /dev/null +++ b/examples/example-implicit-dispatcher/src/main.rs @@ -0,0 +1,23 @@ +//! Example Implicit Dispatcher +//! +//! > This example demonstrates how to use the implicit `dispatcher!` definition syntax enabled by `extra_macros` + +use mingling::prelude::*; + +// When using implicit syntax, the entry and dispatcher names will be automatically derived +dispatcher!("remote.add" /*, CMDRemoteAdd => EntryRemoteAdd */); +dispatcher!("remote.remove", CMDRemoteRemove => EntryRemoteRemove); + +fn main() { + let mut program = ThisProgram::new(); + + // --------- IMPORTANT --------- + program.with_dispatcher(CMDRemoteAdd); + // ^^^^^^^^^^^^\_ CMDRemoteAdd is implicitly created + // --------- IMPORTANT --------- + + program.with_dispatcher(CMDRemoteRemove); + program.exec_and_exit(); +} + +gen_program!(); |
