pub struct ARef<T: AlwaysRefCounted> { /* private fields */ }
Expand description
An owned reference to an always-reference-counted object.
The object’s reference count is automatically decremented when an instance of ARef
is
dropped. It is also automatically incremented when a new instance is created via
ARef::clone
.
Invariants
The pointer stored in ptr
is non-null and valid for the lifetime of the ARef
instance. In
particular, the ARef
instance owns an increment on underlying object’s reference count.
Implementations
sourceimpl<T: AlwaysRefCounted> ARef<T>
impl<T: AlwaysRefCounted> ARef<T>
sourcepub unsafe fn from_raw(ptr: NonNull<T>) -> Self
pub unsafe fn from_raw(ptr: NonNull<T>) -> Self
Creates a new instance of ARef
.
It takes over an increment of the reference count on the underlying object.
Safety
Callers must ensure that the reference count was incremented at least once, and that they
are properly relinquishing one increment. That is, if there is only one increment, callers
must not use the underlying object anymore – it is only safe to do so via the newly
created ARef
.
Trait Implementations
sourceimpl<T: AlwaysRefCounted> Clone for ARef<T>
impl<T: AlwaysRefCounted> Clone for ARef<T>
sourceimpl<T: AlwaysRefCounted> Deref for ARef<T>
impl<T: AlwaysRefCounted> Deref for ARef<T>
sourceimpl<T: AlwaysRefCounted> Drop for ARef<T>
impl<T: AlwaysRefCounted> Drop for ARef<T>
sourceimpl<T: AlwaysRefCounted> From<&'_ T> for ARef<T>
impl<T: AlwaysRefCounted> From<&'_ T> for ARef<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for ARef<T> where
T: RefUnwindSafe,
impl<T> !Send for ARef<T>
impl<T> !Sync for ARef<T>
impl<T> Unpin for ARef<T> where
T: Unpin,
impl<T> UnwindSafe for ARef<T> where
T: UnwindSafe + RefUnwindSafe,
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more