mirror of https://github.com/tauri-apps/tauri
fix(macros): collision when command is named `cmd` (#1802)
This commit is contained in:
parent
1ab8dd93e6
commit
d36b726926
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"tauri-macros": patch
|
||||
---
|
||||
|
||||
Fixes a name collision when the command function is named `cmd`.
|
|
@ -52,11 +52,11 @@ impl From<Handler> for proc_macro::TokenStream {
|
|||
}: Handler,
|
||||
) -> Self {
|
||||
quote::quote!(move |invoke| {
|
||||
let cmd = invoke.message.command();
|
||||
match cmd {
|
||||
let __tauri_cmd__ = invoke.message.command();
|
||||
match __tauri_cmd__ {
|
||||
#(stringify!(#commands) => #wrappers!(#paths, invoke),)*
|
||||
_ => {
|
||||
invoke.resolver.reject(format!("command {} not found", cmd))
|
||||
invoke.resolver.reject(format!("command {} not found", __tauri_cmd__))
|
||||
},
|
||||
}
|
||||
})
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
use tauri::{command, State};
|
||||
|
||||
#[command]
|
||||
pub fn cmd(_argument: String) {}
|
||||
|
||||
#[command]
|
||||
pub fn simple_command(argument: String) {
|
||||
println!("{}", argument);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
// we move some basic commands to a separate module just to show it works
|
||||
mod commands;
|
||||
use commands::cmd;
|
||||
|
||||
use serde::Deserialize;
|
||||
use tauri::{command, Params, State, Window};
|
||||
|
@ -167,6 +168,7 @@ fn main() {
|
|||
force_async_with_result,
|
||||
commands::simple_command,
|
||||
commands::stateful_command,
|
||||
cmd,
|
||||
async_simple_command,
|
||||
future_simple_command,
|
||||
async_stateful_command,
|
||||
|
|
Loading…
Reference in New Issue