tauri-docs
tauri-docs copied to clipboard
[request] fix broken code samples in migration guide
Question you want answered
Fix example code
Where did you look for an answer?
Global shortcut plugin
Reading the migration guide for the global search plugin and checking the rust code snippet. https://v2.tauri.app/start/migrate/from-tauri-1/#migrate-to-global-shortcut-plugin It includes this snippet:
.plugin(
tauri_plugin_global_shortcut::Builder::with_handler(|app, shortcut| {
println!("Shortcut triggered: {:?}", shortcut);
})
.build(),
)
Sadly it does not work:
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> src/lib.rs:28:13
|
28 | tauri_plugin_global_shortcut::Builder::with_handler(|app, shortcut| {
| _____________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^_-
29 | | println!("Shortcut triggered: {:?}", shortcut);
30 | | })
| |_____________- argument #1 of type `tauri_plugin_global_shortcut::Builder<_>` is missing
|
Menu
Similar thing for the menu examples: https://v2.tauri.app/start/migrate/from-tauri-1/#use-taurimenusubmenubuilder
This code
let submenu = SubmenuBuilder::new(app, "Sub")
.text("Tauri")
.separator()
.check("Is Awesome")
.build()?;
also does not work at all:
error[E0061]: this method takes 2 arguments but 1 argument was supplied
--> src/lib.rs:33:14
|
33 | .text("Tauri")
| ^^^^--------- argument #2 is missing
|
note: method defined here
--> /Users/ckoenig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-2.0.2/src/menu/builders/submenu.rs:103:10
|
103 | pub fn text<I: Into<MenuId>, S: AsRef<str>>(mut self, id: I, text: S) -> Self {
| ^^^^
help: provide the argument
|
33 | .text("Tauri", /* text */)
| ~~~~~~~~~~~~~~~~~~~~~
error[E0061]: this method takes 2 arguments but 1 argument was supplied
--> src/lib.rs:35:14
|
35 | .check("Is Awesome")
| ^^^^^-------------- argument #2 is missing
|
note: method defined here
--> /Users/ckoenig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-2.0.2/src/menu/builders/submenu.rs:111:10
|
111 | pub fn check<I: Into<MenuId>, S: AsRef<str>>(mut self, id: I, text: S) -> Self {
| ^^^^^
help: provide the argument
|
35 | .check("Is Awesome", /* text */)
This are the first two snippets that i tried. Maybe there are more errors.
Page URL
https://v2.tauri.app/start/migrate/from-tauri-1/
Additional context
It would be nice if the code snippets of the official migration docs work. Right now it causes a lot of work to upgrade because many things are not documented at all (what permissions does plugin X have, what is the new "gen" folder, etc etc)
Are you willing to work on this yourself?
- [ ] I want to work on this myself