v2 builder.build() type annotations needed
Elendiar opened this issue · 3 comments
Trying to migrate to v2, but cant handle this error. If use in same file with use tauri:{Manager, ...}
- get annotations error.
If use in another module as function that return i can't type the return value.
specta = "=2.0.0-rc.11"
tauri-specta = { version = "=2.0.0-rc.8", features = ["typescript"] }
tauri = "=2.0.0-beta.17"
error[E0283]: type annotations needed
--> src\core\app.rs:135:17
|
135 | builder.build().unwrap()
| ^^^^^ cannot infer type of the type parameter `TManager` declared on the method `build`
|
= note: multiple `impl`s satisfying `_: tauri::Manager<tauri_runtime_wry::Wry<tauri::EventLoopMessage>>` found in the `tauri` crate:
- impl<R> tauri::Manager<R> for tauri::App<R>
where R: tauri::Runtime;
- impl<R> tauri::Manager<R> for tauri::AppHandle<R>
where R: tauri::Runtime;
- impl<R> tauri::Manager<R> for tauri::Webview<R>
where R: tauri::Runtime;
- impl<R> tauri::Manager<R> for tauri::WebviewWindow<R>
where R: tauri::Runtime;
- impl<R> tauri::Manager<R> for tauri::Window<R>
where R: tauri::Runtime;
note: required by a bound in `tauri_specta::Builder::<TLang, TCommands, tauri_specta::Events>::build`
--> X:\packages\cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-specta-2.0.0-rc.8\src\lib.rs:468:28
|
468 | pub fn build<TManager: Manager<TCommands::Runtime>>(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Builder::<TLang, TCommands, Events>::build`
help: consider specifying the generic argument
|
135 | builder.build::<TManager>().unwrap()
| ++++++++++++
You'll need to follow the second note and provide a TManager
generic to build
, and add TManger: tauri::Manager
to your function.
Personally I'd create the builder in a macro_rules
(since that's the part that can really be reused), and call build
in the same places as you use the builder.
EDIT: Just added an example of the latter to the app example.
THanks, I'll try. Seems to work with builder.build::<tauri::App<tauri::Wry>>()
.
ok yeah i guess hardcoding a type works too haha