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 Tis only exposed through the trait methods returning&mut T. -
The implementor must not move out the contained
Tunless the semantics of trait methods demands that. -
Self::dropdropsTin place.
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 Twhere
T: Clone,
unsafe fn strong_count<T>(&self) -> usize
unsafe fn clone<T>(&self) -> Self
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.