diff --git a/examples/app/src-tauri/src/main.rs b/examples/app/src-tauri/src/main.rs index ce54163..72671ec 100644 --- a/examples/app/src-tauri/src/main.rs +++ b/examples/app/src-tauri/src/main.rs @@ -63,8 +63,10 @@ pub struct EmptyEvent; #[derive(Type)] pub struct Custom(String); -fn main() { - let (invoke_handler, register_events) = { +// We recommend re-using the builder via a macro rather than function as the builder's +// generics can be tricky to deal with +macro_rules! specta_builder { + () => {{ let builder = ts::builder() .commands(tauri_specta::collect_commands![ hello_world, @@ -81,8 +83,12 @@ fn main() { #[cfg(debug_assertions)] let builder = builder.path("../src/bindings.ts"); - builder.build().unwrap() - }; + builder + }}; +} + +fn main() { + let (invoke_handler, register_events) = specta_builder!().build().unwrap(); tauri::Builder::default() .invoke_handler(invoke_handler) diff --git a/examples/custom-plugin/plugin/src/lib.rs b/examples/custom-plugin/plugin/src/lib.rs index c8e362b..4f122fb 100644 --- a/examples/custom-plugin/plugin/src/lib.rs +++ b/examples/custom-plugin/plugin/src/lib.rs @@ -14,6 +14,8 @@ fn add_numbers(a: i32, b: i32) -> i32 { #[derive(Clone, serde::Serialize, specta::Type, Event)] struct RandomNumber(i32); +// We recommend re-using the builder via a macro rather than function as the builder's +// generics can be tricky to deal with macro_rules! specta_builder { () => { ts::builder()