From 60e70f5320b2abdb38a2349c18e5bffcfea37ca7 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 24 May 2026 17:06:54 +0800 Subject: Add implicit dispatcher macro with auto-derived names --- examples/example-implicit-dispatcher/src/main.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/example-implicit-dispatcher/src/main.rs (limited to 'examples/example-implicit-dispatcher/src/main.rs') 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!(); -- cgit