Trait ReferenceCounted

Source
pub trait ReferenceCounted<T: ?Sized>: IntoMut<T> + Clone {
    // Required method
    fn reference_count(this: &Self) -> usize;
}
Expand description

A smart pointer that keeps track of how many pointers refer to the same allocation and exposes this information in its API.

Required Methods§

Source

fn reference_count(this: &Self) -> usize

Get the number of owning pointers referring to the same allocation.

Implementations must fulfill that ReferenceCounted::reference_count(this) == 1 implies IntoMut::con_make_mut(this) == true.

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.

Implementors§

Source§

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

Source§

impl<T: ?Sized> ReferenceCounted<T> for Rc<T>