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 MoveRef
s 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
type Uninit = MoveRef<'a, MaybeUninit<T>>
type Uninit = MoveRef<'a, MaybeUninit<T>>
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
“Deinitializes” self
, producing an opaque type that will destroy the
storage of *self
without calling the pointee destructor. Read more