Struct kernel::types::ARef

source ·
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 the underlying object’s reference count.

Implementations§

source§

impl<T: AlwaysRefCounted> ARef<T>

source

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§

source§

impl<T: AlwaysRefCounted> Clone for ARef<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: AlwaysRefCounted> Deref for ARef<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T: AlwaysRefCounted> Drop for ARef<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T: AlwaysRefCounted> From<&T> for ARef<T>

source§

fn from(b: &T) -> Self

Converts to this type from the input type.
source§

impl<T: AlwaysRefCounted + Sync + Send> Send for ARef<T>

source§

impl<T: AlwaysRefCounted + Sync + Send> Sync for ARef<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for ARef<T>where T: RefUnwindSafe,

§

impl<T> Unpin for ARef<T>where T: Unpin,

§

impl<T> UnwindSafe for ARef<T>where T: UnwindSafe + RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, E> Init<T, E> for T

source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, E> PinInit<T, E> for T

source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.