SharedPointerKind

Trait SharedPointerKind 

Source
pub unsafe trait SharedPointerKind: Sized + Debug {
    // Required methods
    fn new<T>(v: T) -> Self;
    fn from_box<T>(v: Box<T>) -> Self;
    unsafe fn as_ptr<T>(&self) -> *const T;
    unsafe fn deref<T>(&self) -> &T;
    unsafe fn try_unwrap<T>(self) -> Result<T, Self>;
    unsafe fn get_mut<T>(&mut self) -> Option<&mut T>;
    unsafe fn make_mut<T>(&mut self) -> &mut T
       where T: Clone;
    unsafe fn strong_count<T>(&self) -> usize;
    unsafe fn clone<T>(&self) -> Self;
    unsafe fn drop<T>(&mut self);
}
Expand description

Trait for type constructors of reference-counting pointers.

§Safety

T may be !Unpin, and SharedPointer may be held in a pinned form (Pin<SharedPointer<T, Self>>). As such, the implementation of this trait must uphold the pinning invariants for T while it’s held in Self. Specifically, this necessitates the following:

  • &mut T is only exposed through the trait methods returning &mut T.

  • The implementor must not move out the contained T unless the semantics of trait methods demands that.

  • Self::drop drops T in place.

Required Methods§

Source

fn new<T>(v: T) -> Self

Source

fn from_box<T>(v: Box<T>) -> Self

Source

unsafe fn as_ptr<T>(&self) -> *const T

Source

unsafe fn deref<T>(&self) -> &T

Source

unsafe fn try_unwrap<T>(self) -> Result<T, Self>

Source

unsafe fn get_mut<T>(&mut self) -> Option<&mut T>

Source

unsafe fn make_mut<T>(&mut self) -> &mut T
where T: Clone,

Source

unsafe fn strong_count<T>(&self) -> usize

Source

unsafe fn clone<T>(&self) -> Self

Source

unsafe fn drop<T>(&mut self)

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§