Skip to main content

WeakWell

Trait WeakWell 

Source
pub unsafe trait WeakWell: Well {
    type Strong: StrongWell + Deref<Target = Self::Target>;

    // Required methods
    fn access(&self) -> Option<Self::Strong>;
    fn weaken(access: &Self::Strong) -> Self;
}
Expand description

Smart pointer without direct access to its data.

§Safety

Implementors of this trait assert that insert and remove calls of themselves and their Strong variant can be interchanged as long as the number of “weak” and “strong” versions remain the same.

Required Associated Types§

Source

type Strong: StrongWell + Deref<Target = Self::Target>

Smart pointer that can directly access data.

Required Methods§

Source

fn access(&self) -> Option<Self::Strong>

Attempts to access data inside the well.

Source

fn weaken(access: &Self::Strong) -> Self

Converts strong well back into weak version.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> WeakWell for Weak<T>

Available on crate feature alloc only.
Source§

type Strong = Rc<T>

Source§

fn access(&self) -> Option<Rc<T>>

Source§

fn weaken(access: &Rc<T>) -> Weak<T>

Source§

impl<T> WeakWell for Weak<T>

Available on crate features alloc only.
Source§

type Strong = Arc<T>

Source§

fn access(&self) -> Option<Arc<T>>

Source§

fn weaken(access: &Arc<T>) -> Weak<T>

Implementors§