Trait StrongRef

Source
pub trait StrongRef {
    type Weak: WeakRef<Strong = Self>;

    // Required methods
    fn downgrade(&self) -> Self::Weak;
    fn ptr_eq(&self, other: &Self) -> bool;
}
Expand description

A trait for strong references.

Required Associated Types§

Source

type Weak: WeakRef<Strong = Self>

The type of the weak reference.

For example, for std::rc::Rc<T>, this will be std::rc::Weak<T>.

Required Methods§

Source

fn downgrade(&self) -> Self::Weak

Constructs a weak reference from a strong reference.

This is usually implemented by a downgrade method.

Source

fn ptr_eq(&self, other: &Self) -> bool

Compare two strong references for equality.

This is usually implemented by a ptr_eq method.

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: ?Sized> StrongRef for Rc<T>

Source§

type Weak = Weak<T>

Source§

fn downgrade(&self) -> Self::Weak

Source§

fn ptr_eq(&self, other: &Self) -> bool

Source§

impl<T: ?Sized> StrongRef for Arc<T>

Source§

type Weak = Weak<T>

Source§

fn downgrade(&self) -> Self::Weak

Source§

fn ptr_eq(&self, other: &Self) -> bool

Implementors§