Struct moveit::move_ref::MoveRef[][src]

pub struct MoveRef<'a, T: ?Sized> { /* fields omitted */ }
Expand description

A library emulation of the theoretical &move T type.

A MoveRef<'a, T> represents a unique reference to T for the lifetime 'a. Unlike an &mut T, though, a MoveRef<T> is the longest-lived such reference, entitling it to run T’s destructor. In other words, MoveRef<T> owns its referent, but not its referent’s storage. See the module docs for more information.

The main mechanism for obtaining MoveRefs is the moveit!() macro, which is analogous to a theoretical &move expr operator. This actuates a DerefMove implementation.

Implementations

Create a new MoveRef<T> out of a mutable reference.

Safety

ptr must satisfy the longest-lived criterion: after the return value goes out of scope, ptr must also be out-of-scope. Calling this function correctly is non-trivial, and should be left to moveit!() instead.

In particular, if ptr outlives the returned MoveRef, it will point to dropped memory, which is UB.

Convert a MoveRef<T> into a Pin<MoveRef<T>>.

Because we own the referent, we are entitled to pin it permanently. See Box::into_pin() for a standard-library equivalent.

Consume the MoveRef<T>, returning the wrapped value.

Trait Implementations

The resulting type after dereferencing.

Dereferences the value.

An “uninitialized” version of Self. Read more

“Deinitializes” self, producing an opaque type that will destroy the storage of *self without calling the pointee destructor. Read more

Moves out of this, producing a MoveRef that owns its contents. Read more

An “uninitialized” version of Self. Read more

“Deinitializes” self, producing an opaque type that will destroy the storage of *self without calling the pointee destructor. Read more

Moves out of this, producing a MoveRef that owns its contents. Read more

Mutably dereferences the value.

Executes the destructor for this type. Read more

Performs the conversion.

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 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.