Struct WeakDispatch
struct WeakDispatch { ... }
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: &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!;
impl Clone for WeakDispatch
fn clone(self: &Self) -> WeakDispatch
impl Debug for WeakDispatch
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Freeze for WeakDispatch
impl RefUnwindSafe for WeakDispatch
impl Send for WeakDispatch
impl Sync for WeakDispatch
impl Unpin for WeakDispatch
impl UnsafeUnpin for WeakDispatch
impl UnwindSafe for WeakDispatch
impl<T> Any for WeakDispatch
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for WeakDispatch
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for WeakDispatch
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for WeakDispatch
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for WeakDispatch
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for WeakDispatch
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for WeakDispatch
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for WeakDispatch
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for WeakDispatch
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>