Struct kernel::sync::Ref[][src]

pub struct Ref<T: ?Sized> { /* fields omitted */ }
Expand description

A reference-counted pointer to an instance of T.

The reference count is incremented when new instances of Ref are created, and decremented when they are dropped. When the count reaches zero, the underlying T is also dropped.

Invariants

The reference count on an instance of Ref is always non-zero. The object pointed to by Ref is always pinned.

Implementations

Constructs a new reference counted instance of T.

Constructs a new reference counted instance of T and calls the initialisation function.

This is useful because it provides a mutable reference to T at its final location.

Deconstructs a Ref object into a usize.

It can be reconstructed once via Ref::from_usize.

Borrows a Ref instance previously deconstructed via Ref::into_usize.

Safety

encoded must have been returned by a previous call to Ref::into_usize. Additionally, Ref::from_usize can only be called after all instances of RefBorrow have been dropped.

Recreates a Ref instance previously deconstructed via Ref::into_usize.

Safety

encoded must have been returned by a previous call to Ref::into_usize. Additionally, it can only be called once for each previous call to ``Ref::into_usize`.

Determines if two reference-counted pointers point to the same underlying instance of T.

Returns a pinned version of a given Ref instance.

Trait Implementations

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The resulting type after dereferencing.

Dereferences the value.

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.