pub struct RawBox<T: ?Sized, S: Storage> { /* private fields */ }
Expand description

A raw box around some storage. Bundles the storage and its handle.

Implementations

Create a new box for the object described by the given metadata.

The object is not initialized.

(Do we want a new_zeroed?)

Safety
  • The metadata must describe a layout valid for a rust object.
    • This requirement exists due to the safety requirements of size_of_val_raw and align_of_val_raw. I think we definitely want a way to go compute layout from type and metadata safely, with a check that it produces a valid layout.
    • On each unsized kind, this would imply:
      • slices: size computation uses saturating/checked multiplication.
      • traits: vtable must always be valid (as a safety invariant).
      • composites: size computation uses saturating/checked addition.
      • externs: any valid metadata must compute valid size/align or indicates that size/align is unknown and/or needs a valid object.
    • rust-lang/rust#95832 is an attempt to quantize how expensive it would be to make slice size computation always use saturating math.

Get a reference to the boxed object.

Get a pointer valid for reads only to the boxed object.

The pointer is invalidated when the box is moved or used by mutable reference.

Get a mutable reference to the boxed object.

Get a pointer valid for reads and writes to the boxed object.

The pointer is invalidated when the box is moved or used by reference.

Get the metadata of the boxed object.

Break a raw box into its component parts.

Reassemble a raw box from its component parts.

Trait Implementations

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

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 returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.