mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-28 03:47:37 +03:00
refactor(core): return state in unmanage
(#11105)
* refactor(core): return state in `unmanage` * Update crates/tauri/src/lib.rs [skip ci] Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de> --------- Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app> Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
This commit is contained in:
parent
4078923f6b
commit
8f3f010e6d
@ -699,12 +699,12 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
|
||||
self.manager().state().set(state)
|
||||
}
|
||||
|
||||
/// Removes the state managed by the application for T. Returns `true` if it was actually removed
|
||||
fn unmanage<T>(&self) -> bool
|
||||
/// Removes the state managed by the application for T. Returns the state if it was actually removed.
|
||||
fn unmanage<T>(&self) -> Option<T>
|
||||
where
|
||||
T: Send + Sync + 'static,
|
||||
{
|
||||
self.manager().state().unmanage::<T>()
|
||||
self.manager().state().unmanage()
|
||||
}
|
||||
|
||||
/// Retrieves the managed state for the type `T`.
|
||||
|
@ -140,10 +140,12 @@ impl StateManager {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn unmanage<T: Send + Sync + 'static>(&self) -> bool {
|
||||
pub(crate) fn unmanage<T: Send + Sync + 'static>(&self) -> Option<T> {
|
||||
self.with_map_mut(|map| {
|
||||
let type_id = TypeId::of::<T>();
|
||||
map.remove(&type_id).is_some()
|
||||
map
|
||||
.remove(&type_id)
|
||||
.and_then(|ptr| ptr.downcast().ok().map(|b| *b))
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user