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

A memory location that may or may not have a value initialized in it.

Implementations

Returns the layout of the pointer held in the slot.

Creates a new slot from an exclusive pointer.

Safety
  • ptr must be non-null, properly aligned, and valid for reads and writes.
  • ptr must not alias any other accessible references for 'a.

Gets a shared reference to the value in the slot.

Safety

The contents of the slot must be initialized. See assume_init for details.

Gets a mutable reference to the value in the slot.

Safety

The contents of the slot must be initialized. See assume_init for details.

Drops the value in the slot.

Safety

The contents of the slot must be initialized. See assume_init for details.

Gets a pointer to the underlying memory.

Gets a mutable borrow from this slot.

Writes zeroes to every byte of the backing memory.

Returns a slot of the underlying bytes.

Attempts to cast the type of the Slot from T to U.

Returns None if U requires a higher alignment than the pointer in self or U is larger than T.

Casts the type of the Slot from T to U.

Safety

The slot must point to memory suitable for holding a U. In addition to being the right size and aligment, the caller must also guarantee that the slot pointer will not alias any other accessible references after being cast.

Returns a new Slot backed by the given MaybeUninit.

Sets the value of the Slot.

This overwrites any previous value without dropping it, so be careful not to use this after initializing the slot unless you want to skip running the destructor.

Because this method does not convert the Slot to a value, the written value will not be dropped when the returned reference or underlying Slot leave scope.

Returns a reference to the underlying memory as a MaybeUninit.

Returns a reference to the underlying memory as a mutable MaybeUninit.

Returns the length of the pointed-to array.

Returns whether the pointed-to array is empty.

Gets an element of the slot array.

Gets an element of the slot array without doing bounds checking.

For a safe alternative, see get.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Converts an slot array to an slot slice of the same length.

Returns the length of the pointed-to slice.

Returns whether the pointed-to slice is empty.

Gets an element of the slot slice.

Gets an element of the slot slice without doing bounds checking.

For a safe alternative, see get.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Trait Implementations

The underlying type that is destructured.
The type of destructuring to perform.
Returns a mutable pointer to the underlying type.
The target value of this type.
Returns a pointer to this type’s target.
The restructured version of this type.
Restructures a pointer to this type into the target 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

Returns the argument unchanged.

Calls U::from(self).

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

The type for metadata in pointers and references to Self.
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.