From 79b3dcaa75a20dcb8ab850dacd3acb082b78adb2 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sun, 18 Jun 2023 07:11:04 -0300 Subject: [PATCH 1/2] docs(core): fix panic section on `manage` documentation --- core/tauri/src/app.rs | 8 ++------ core/tauri/src/lib.rs | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/core/tauri/src/app.rs b/core/tauri/src/app.rs index dcb965cdaed..d162b481c45 100644 --- a/core/tauri/src/app.rs +++ b/core/tauri/src/app.rs @@ -1207,17 +1207,13 @@ impl Builder { /// Add `state` to the state managed by the application. /// - /// This method can be called any number of times as long as each call - /// refers to a different `T`. + /// If the state for the `T` type has previously been set, the state is unchanged and false is returned. Otherwise true is returned. /// /// Managed state can be retrieved by any command handler via the /// [`State`](crate::State) guard. In particular, if a value of type `T` /// is managed by Tauri, adding `State` to the list of arguments in a /// command handler instructs Tauri to retrieve the managed value. - /// - /// # Panics - /// - /// Panics if state of type `T` is already being managed. + /// Additionally, [`state`](crate::Manager#method.state) can be used to retrieve the value manually. /// /// # Mutability /// diff --git a/core/tauri/src/lib.rs b/core/tauri/src/lib.rs index 32c86cc9237..7be4034ca2d 100644 --- a/core/tauri/src/lib.rs +++ b/core/tauri/src/lib.rs @@ -756,18 +756,13 @@ pub trait Manager: sealed::ManagerBase { /// Add `state` to the state managed by the application. /// - /// This method can be called any number of times as long as each call - /// refers to a different `T`. - /// If a state for `T` is already managed, the function returns false and the value is ignored. + /// If the state for the `T` type has previously been set, the state is unchanged and false is returned. Otherwise true is returned. /// /// Managed state can be retrieved by any command handler via the /// [`State`](crate::State) guard. In particular, if a value of type `T` /// is managed by Tauri, adding `State` to the list of arguments in a /// command handler instructs Tauri to retrieve the managed value. - /// - /// # Panics - /// - /// Panics if state of type `T` is already being managed. + /// Additionally, [`state`](Self#method.state) can be used to retrieve the value manually. /// /// # Mutability /// From 627bc27362511e6c17582d82fb95a967a2e594ed Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Tue, 20 Jun 2023 16:59:14 -0300 Subject: [PATCH 2/2] fix Builder::manage docs --- core/tauri/src/app.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/tauri/src/app.rs b/core/tauri/src/app.rs index d162b481c45..97652556f28 100644 --- a/core/tauri/src/app.rs +++ b/core/tauri/src/app.rs @@ -1207,7 +1207,8 @@ impl Builder { /// Add `state` to the state managed by the application. /// - /// If the state for the `T` type has previously been set, the state is unchanged and false is returned. Otherwise true is returned. + /// This method can be called any number of times as long as each call + /// refers to a different `T`. /// /// Managed state can be retrieved by any command handler via the /// [`State`](crate::State) guard. In particular, if a value of type `T` @@ -1215,6 +1216,10 @@ impl Builder { /// command handler instructs Tauri to retrieve the managed value. /// Additionally, [`state`](crate::Manager#method.state) can be used to retrieve the value manually. /// + /// # Panics + /// + /// Panics if state of type `T` is already being managed. + /// /// # Mutability /// /// Since the managed state is global and must be [`Send`] + [`Sync`], mutations can only happen through interior mutability: