From 981d244df444d3dcf48dee558109231da7e6a61b Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Thu, 26 Feb 2026 01:11:19 +0800 Subject: Change cmd_output! macro to take type before value --- src/systems/cmd/macros.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/systems/cmd') diff --git a/src/systems/cmd/macros.rs b/src/systems/cmd/macros.rs index 454ad30..efb14f7 100644 --- a/src/systems/cmd/macros.rs +++ b/src/systems/cmd/macros.rs @@ -76,7 +76,7 @@ /// todo!(); /// /// // Use the following method to return results -/// cmd_output!(output, JVCustomOutput) +/// cmd_output!(JVCustomOutput => output) /// } /// ``` /// @@ -119,7 +119,7 @@ /// collect: Collect, /// ) -> Result<(Box, TypeId), CmdExecuteError> { /// todo!(); -/// cmd_output!(output, JVCustomOutput) +/// cmd_output!(JVCustomOutput => output) /// } /// ``` macro_rules! command_template { @@ -162,10 +162,11 @@ macro_rules! command_template { #[macro_export] macro_rules! cmd_output { - ($v:expr, $t:ty) => { + ($t:ty => $v:expr) => {{ + let checked_value: $t = $v; Ok(( - Box::new($v) as Box, + Box::new(checked_value) as Box, std::any::TypeId::of::<$t>(), )) - }; + }}; } -- cgit