Struct WeakDispatch
pub struct WeakDispatch { /* private fields */ }
WeakDispatch is a version of Dispatch that holds a non-owning reference
to a Subscriber.
The Subscriber may be accessed by calling WeakDispatch::upgrade,
which returns an Option<Dispatch>. If all Dispatch clones that point
at the Subscriber have been dropped, WeakDispatch::upgrade will return
None. Otherwise, it will return Some(Dispatch).
A WeakDispatch may be created from a Dispatch by calling the
Dispatch::downgrade method. The primary use for creating a
WeakDispatch is to allow a Subscriber` to hold a cyclical reference to
itself without creating a memory leak. See here for details.
This type is analogous to the std::sync::Weak type, but for a
Dispatch rather than an Arc.
Implementations
impl WeakDispatch
fn upgrade(&self) -> Option<Dispatch>Attempts to upgrade this
WeakDispatchto aDispatch.Returns
Noneif the referencedDispatchhas already been dropped.Examples
# use NoSubscriber; # use Dispatch; let strong = new; let weak = strong.downgrade; // The strong here keeps it alive, so we can still access the object. assert!; drop; // But not any more. assert!;
Trait Implementations
impl Clone for WeakDispatch
fn clone(&self) -> WeakDispatch
impl Debug for WeakDispatch
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl !RefUnwindSafe for WeakDispatch
impl !UnwindSafe for WeakDispatch
impl Freeze for WeakDispatch
impl Send for WeakDispatch
impl Sync for WeakDispatch
impl Unpin for WeakDispatch
impl UnsafeUnpin for WeakDispatch
Blanket Implementations
impl<T> Any for WeakDispatch
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for WeakDispatch
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for WeakDispatch
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for WeakDispatch
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for WeakDispatch
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for WeakDispatch
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for WeakDispatch
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for WeakDispatch
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for WeakDispatch
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>