#[repr(C)]pub struct SharedPtr<T> where
T: SharedPtrTarget, { /* private fields */ }
Expand description
Binding to C++ std::shared_ptr<T>
.
Implementations
sourceimpl<T> SharedPtr<T> where
T: SharedPtrTarget,
impl<T> SharedPtr<T> where
T: SharedPtrTarget,
sourcepub fn null() -> Self
pub fn null() -> Self
Makes a new SharedPtr wrapping a null pointer.
Matches the behavior of default-constructing a std::shared_ptr.
sourcepub fn new(value: T) -> Self where
T: ExternType<Kind = Trivial>,
pub fn new(value: T) -> Self where
T: ExternType<Kind = Trivial>,
Allocates memory on the heap and makes a SharedPtr owner for it.
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Checks whether the SharedPtr does not own an object.
This is the opposite of std::shared_ptr<T>::operator bool.
sourcepub fn as_ref(&self) -> Option<&T>
pub fn as_ref(&self) -> Option<&T>
Returns a reference to the object owned by this SharedPtr if any, otherwise None.
sourcepub fn downgrade(self: &SharedPtr<T>) -> WeakPtr<T> where
T: WeakPtrTarget,
pub fn downgrade(self: &SharedPtr<T>) -> WeakPtr<T> where
T: WeakPtrTarget,
Constructs new WeakPtr as a non-owning reference to the object managed
by self
. If self
manages no object, the WeakPtr manages no object
too.
Matches the behavior of std::weak_ptr<T>::weak_ptr(const std::shared_ptr<T> &).
Trait Implementations
sourceimpl<T> Clone for SharedPtr<T> where
T: SharedPtrTarget,
impl<T> Clone for SharedPtr<T> where
T: SharedPtrTarget,
sourceimpl<T> Debug for SharedPtr<T> where
T: Debug + SharedPtrTarget,
impl<T> Debug for SharedPtr<T> where
T: Debug + SharedPtrTarget,
sourceimpl<T> Deref for SharedPtr<T> where
T: SharedPtrTarget,
impl<T> Deref for SharedPtr<T> where
T: SharedPtrTarget,
sourceimpl<T> Display for SharedPtr<T> where
T: Display + SharedPtrTarget,
impl<T> Display for SharedPtr<T> where
T: Display + SharedPtrTarget,
sourceimpl<T> Drop for SharedPtr<T> where
T: SharedPtrTarget,
impl<T> Drop for SharedPtr<T> where
T: SharedPtrTarget,
impl<T> Send for SharedPtr<T> where
T: Send + Sync + SharedPtrTarget,
impl<T> Sync for SharedPtr<T> where
T: Send + Sync + SharedPtrTarget,
Auto Trait Implementations
impl<T> RefUnwindSafe for SharedPtr<T> where
T: RefUnwindSafe,
impl<T> Unpin for SharedPtr<T> where
T: Unpin,
impl<T> UnwindSafe for SharedPtr<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more