diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-02-26 00:51:45 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-02-26 01:02:42 +0800 |
| commit | e3aeb6a1c9955eee2c396230317e63becd24ec6a (patch) | |
| tree | 5c70b2a73fb32ed1a717463c81a99e346d3c25e6 /src/systems/cmd/macros.rs | |
| parent | ae06e0b30a328508f48c108fabcccdf1d23c5643 (diff) | |
Replace string type identifiers with TypeId for command output matching
Diffstat (limited to 'src/systems/cmd/macros.rs')
| -rw-r--r-- | src/systems/cmd/macros.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/systems/cmd/macros.rs b/src/systems/cmd/macros.rs index 23a277c..454ad30 100644 --- a/src/systems/cmd/macros.rs +++ b/src/systems/cmd/macros.rs @@ -12,6 +12,7 @@ /// Then paste the following content into your code /// /// ```ignore +/// use std::any::TypeId; /// use cmd_system_macros::exec; /// use crate::{ /// cmd_output, @@ -71,7 +72,7 @@ /// async fn exec( /// input: In, /// collect: Collect, -/// ) -> Result<(Box<dyn std::any::Any + Send + 'static>, String), CmdExecuteError> { +/// ) -> Result<(Box<dyn std::any::Any + Send + 'static>, TypeId), CmdExecuteError> { /// todo!(); /// /// // Use the following method to return results @@ -82,6 +83,7 @@ /// Of course, you can also use the comment-free version /// /// ```ignore +/// use std::any::TypeId; /// use cmd_system_macros::exec; /// use crate::{ /// cmd_output, @@ -115,7 +117,7 @@ /// async fn exec( /// input: In, /// collect: Collect, -/// ) -> Result<(Box<dyn std::any::Any + Send + 'static>, String), CmdExecuteError> { +/// ) -> Result<(Box<dyn std::any::Any + Send + 'static>, TypeId), CmdExecuteError> { /// todo!(); /// cmd_output!(output, JVCustomOutput) /// } @@ -145,7 +147,7 @@ macro_rules! command_template { input: In, collect: Collect, ) -> Result< - (Box<dyn std::any::Any + Send + 'static>, String), + (Box<dyn std::any::Any + Send + 'static>, std::any::TypeId), $crate::systems::cmd::errors::CmdExecuteError, > { exec(input, collect).await @@ -163,7 +165,7 @@ macro_rules! cmd_output { ($v:expr, $t:ty) => { Ok(( Box::new($v) as Box<dyn std::any::Any + Send + 'static>, - stringify!($t).to_string(), + std::any::TypeId::of::<$t>(), )) }; } |
