diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmds/cmd/hexdump.rs | 2 | ||||
| -rw-r--r-- | src/cmds/cmd/sheetdump.rs | 2 | ||||
| -rw-r--r-- | src/cmds/cmd/status.rs | 2 | ||||
| -rw-r--r-- | src/systems/cmd/macros.rs | 11 |
4 files changed, 9 insertions, 8 deletions
diff --git a/src/cmds/cmd/hexdump.rs b/src/cmds/cmd/hexdump.rs index 82f5d45..66022ef 100644 --- a/src/cmds/cmd/hexdump.rs +++ b/src/cmds/cmd/hexdump.rs @@ -40,7 +40,7 @@ async fn exec( collect: Collect, ) -> Result<(Box<dyn std::any::Any + Send + 'static>, TypeId), CmdExecuteError> { let output = JVHexOutput { data: collect.data }; - cmd_output!(output, JVHexOutput) + cmd_output!(JVHexOutput => output) } crate::command_template!(); diff --git a/src/cmds/cmd/sheetdump.rs b/src/cmds/cmd/sheetdump.rs index defb8ff..1945f44 100644 --- a/src/cmds/cmd/sheetdump.rs +++ b/src/cmds/cmd/sheetdump.rs @@ -58,7 +58,7 @@ async fn exec( let result = JVMappingsOutput { mappings: mappings_vec, }; - cmd_output!(result, JVMappingsOutput) + cmd_output!(JVMappingsOutput => result) } crate::command_template!(); diff --git a/src/cmds/cmd/status.rs b/src/cmds/cmd/status.rs index 5d5f4a3..3ca2a25 100644 --- a/src/cmds/cmd/status.rs +++ b/src/cmds/cmd/status.rs @@ -150,7 +150,7 @@ async fn exec( now_time: collect.now_time, }; - cmd_output!(output, JVStatusOutput) + cmd_output!(JVStatusOutput => output) } crate::command_template!(); 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<dyn std::any::Any + Send + 'static>, 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<dyn std::any::Any + Send + 'static>, + Box::new(checked_value) as Box<dyn std::any::Any + Send + 'static>, std::any::TypeId::of::<$t>(), )) - }; + }}; } |
