diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-05-24 17:06:54 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-24 17:06:54 +0800 |
| commit | 60e70f5320b2abdb38a2349c18e5bffcfea37ca7 (patch) | |
| tree | 3402af0a2822255c1c3f9c77affe6da81c9d1279 /examples/example-implicit-dispatcher/src | |
| parent | 11adad7db1b6202d5366527902c3f0a9fb90654f (diff) | |
Add implicit dispatcher macro with auto-derived names
Diffstat (limited to 'examples/example-implicit-dispatcher/src')
| -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!(); |
