Struct ptr_union::Union4

source ·
pub struct Union4<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr = NeverPtr> { /* private fields */ }
Expand description

A pointer union of four pointer types.

This is a tagged union of four pointer types such as Box, Arc, or & that is only as big as a single pointer. This is accomplished by storing the tag in the alignment bits of the pointer.

As such, the pointer must be aligned to at least u32 (align(4)). This is enforced through the use of Builder4.

The fourth pointer type may be omitted to create a three pointer union. The default type, NeverPtr, will be an alias for ! once it is stable. This will not be considered a breaking change.

Implementations§

Construct a varaint of this union with a dynamic alignment check.

Check if the union is this variant.

Extract this variant from the union.

Returns the union on error.

Run a closure with this variant.

Get a reference to this variant’s target.

Clone this variant out of the union.

Copy this variant out of the union.

Construct a varaint of this union with a dynamic alignment check.

Check if the union is this variant.

Extract this variant from the union.

Returns the union on error.

Run a closure with this variant.

Get a reference to this variant’s target.

Clone this variant out of the union.

Copy this variant out of the union.

Construct a varaint of this union with a dynamic alignment check.

Check if the union is this variant.

Extract this variant from the union.

Returns the union on error.

Run a closure with this variant.

Get a reference to this variant’s target.

Clone this variant out of the union.

Copy this variant out of the union.

Construct a varaint of this union with a dynamic alignment check.

Check if the union is this variant.

Extract this variant from the union.

Returns the union on error.

Run a closure with this variant.

Get a reference to this variant’s target.

Clone this variant out of the union.

Copy this variant out of the union.

Unpack this union into an enum.

Check if two unions are the same variant and point to the same value (not that the values compare as equal).

Dereference the current pointer.

Dereference the current pointer.

Safety

The reference produced must be properly aligned. Note that only the actually produced reference is restricted, not the result of dereferencing any of the other types in this union.

Get the raw type-erased untagged pointer to the payload.

Dereference the current pointer.

Performs a dynamic alignment check on the dereferenced pointer.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
Turn this erasable pointer into an erased pointer. Read more
Unerase this erased pointer. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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
Unerase this erased pointer. Read more
Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
Turn this erasable pointer into an erased pointer. 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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.