From 3f3599b9cc238da06b36aff4c120a013a97fc3f0 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Mon, 27 Dec 2021 10:50:38 -0300 Subject: [PATCH] refactor(core): change `setup` closure type to `FnOnce`, closes #3061 (#3065) --- .changes/setup-fn-once.md | 5 +++++ core/tauri/src/app.rs | 2 +- core/tauri/src/hooks.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changes/setup-fn-once.md diff --git a/.changes/setup-fn-once.md b/.changes/setup-fn-once.md new file mode 100644 index 000000000..7f06a05ed --- /dev/null +++ b/.changes/setup-fn-once.md @@ -0,0 +1,5 @@ +--- +"tauri": "patch" +--- + +`Builder#setup` closure type changed from `Fn` to `FnOnce`. diff --git a/core/tauri/src/app.rs b/core/tauri/src/app.rs index 2e0913b83..1804cd47e 100644 --- a/core/tauri/src/app.rs +++ b/core/tauri/src/app.rs @@ -677,7 +677,7 @@ impl Builder { /// Defines the setup hook. pub fn setup(mut self, setup: F) -> Self where - F: Fn(&mut App) -> Result<(), Box> + Send + 'static, + F: FnOnce(&mut App) -> Result<(), Box> + Send + 'static, { self.setup = Box::new(setup); self diff --git a/core/tauri/src/hooks.rs b/core/tauri/src/hooks.rs index dfe917a7d..3d9d199a2 100644 --- a/core/tauri/src/hooks.rs +++ b/core/tauri/src/hooks.rs @@ -16,7 +16,7 @@ use tauri_macros::default_runtime; /// A closure that is run when the Tauri application is setting up. pub type SetupHook = - Box) -> Result<(), Box> + Send>; + Box) -> Result<(), Box> + Send>; /// A closure that is run everytime Tauri receives a message it doesn't explicitly handle. pub type InvokeHandler = dyn Fn(Invoke) + Send + Sync + 'static;