pub struct Disposer { /* private fields */ }Expand description
A handle that withdraws one registration.
Dropping it does nothing. Undoing on drop would be the more idiomatic
Rust shape, but it makes the overwhelmingly common call —
registry.register(tool); with the result ignored — silently unregister
the tool it just added. Withdrawal is therefore explicit: hold the handle
if you will need it, ignore it if you will not.
Not #[must_use]: the overwhelmingly common case is registering something
for the lifetime of the process and never withdrawing it, and a lint on
every one of those would be noise that teaches people to silence lints.
Implementations§
Source§impl Disposer
impl Disposer
pub fn new( id: RegistrationId, undo: impl FnOnce(RegistrationId) + Send + Sync + 'static, ) -> Self
Sourcepub fn inert(id: RegistrationId) -> Self
pub fn inert(id: RegistrationId) -> Self
A handle over a registration that cannot be withdrawn — for an implementation whose contents are fixed after construction.
pub fn id(&self) -> RegistrationId
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Disposer
impl !UnwindSafe for Disposer
impl Forget for Disposer
impl Freeze for Disposerwhere
*const dyn FnOnce(RegistrationId) + Send + Sync is !null: Freeze,
PhantomData<dyn FnOnce(RegistrationId) + Send + Sync>: Freeze,
impl Move for Disposer
impl Send for Disposer
impl Sync for Disposer
impl Unpin for Disposer
impl UnsafeUnpin for Disposerwhere
*const dyn FnOnce(RegistrationId) + Send + Sync is !null: UnsafeUnpin,
PhantomData<dyn FnOnce(RegistrationId) + Send + Sync>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more