Skip to content

Commit 3f3599b

Browse files
authored
refactor(core): change setup closure type to FnOnce, closes #3061 (#3065)
1 parent 35588b2 commit 3f3599b

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

.changes/setup-fn-once.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": "patch"
3+
---
4+
5+
`Builder#setup` closure type changed from `Fn` to `FnOnce`.

core/tauri/src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ impl<R: Runtime> Builder<R> {
677677
/// Defines the setup hook.
678678
pub fn setup<F>(mut self, setup: F) -> Self
679679
where
680-
F: Fn(&mut App<R>) -> Result<(), Box<dyn std::error::Error + Send>> + Send + 'static,
680+
F: FnOnce(&mut App<R>) -> Result<(), Box<dyn std::error::Error + Send>> + Send + 'static,
681681
{
682682
self.setup = Box::new(setup);
683683
self

core/tauri/src/hooks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use tauri_macros::default_runtime;
1616

1717
/// A closure that is run when the Tauri application is setting up.
1818
pub type SetupHook<R> =
19-
Box<dyn Fn(&mut App<R>) -> Result<(), Box<dyn std::error::Error + Send>> + Send>;
19+
Box<dyn FnOnce(&mut App<R>) -> Result<(), Box<dyn std::error::Error + Send>> + Send>;
2020

2121
/// A closure that is run everytime Tauri receives a message it doesn't explicitly handle.
2222
pub type InvokeHandler<R> = dyn Fn(Invoke<R>) + Send + Sync + 'static;

0 commit comments

Comments
 (0)