pub struct Union16<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr, I: ErasablePtr, J: ErasablePtr = NeverPtr, K: ErasablePtr = NeverPtr, L: ErasablePtr = NeverPtr, M: ErasablePtr = NeverPtr, N: ErasablePtr = NeverPtr, O: ErasablePtr = NeverPtr, P: ErasablePtr = NeverPtr> { /* private fields */ }
Expand description
A pointer union of up to sixteen pointer types.
This is a tagged union of sixteen 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 align(16)
.
This is enforced through the use of Builder16
.
Pointers beyond the ninth may be ommitted to create smaller unions.
The default type, NeverPtr
, will be an alias for !
once it is stable.
This will not be considered a breaking change.
Implementations§
source§impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr, I: ErasablePtr, J: ErasablePtr, K: ErasablePtr, L: ErasablePtr, M: ErasablePtr, N: ErasablePtr, O: ErasablePtr, P: ErasablePtr> Union16<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr, I: ErasablePtr, J: ErasablePtr, K: ErasablePtr, L: ErasablePtr, M: ErasablePtr, N: ErasablePtr, O: ErasablePtr, P: ErasablePtr> Union16<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>
sourcepub fn new_a(a: A) -> Result<Self, A>
pub fn new_a(a: A) -> Result<Self, A>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_a(self) -> Result<A, Self>
pub fn into_a(self) -> Result<A, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_b(b: B) -> Result<Self, B>
pub fn new_b(b: B) -> Result<Self, B>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_b(self) -> Result<B, Self>
pub fn into_b(self) -> Result<B, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_c(c: C) -> Result<Self, C>
pub fn new_c(c: C) -> Result<Self, C>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_c(self) -> Result<C, Self>
pub fn into_c(self) -> Result<C, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_d(d: D) -> Result<Self, D>
pub fn new_d(d: D) -> Result<Self, D>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_d(self) -> Result<D, Self>
pub fn into_d(self) -> Result<D, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_e(e: E) -> Result<Self, E>
pub fn new_e(e: E) -> Result<Self, E>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_e(self) -> Result<E, Self>
pub fn into_e(self) -> Result<E, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_f(f: F) -> Result<Self, F>
pub fn new_f(f: F) -> Result<Self, F>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_f(self) -> Result<F, Self>
pub fn into_f(self) -> Result<F, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_g(g: G) -> Result<Self, G>
pub fn new_g(g: G) -> Result<Self, G>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_g(self) -> Result<G, Self>
pub fn into_g(self) -> Result<G, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_h(h: H) -> Result<Self, H>
pub fn new_h(h: H) -> Result<Self, H>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_h(self) -> Result<H, Self>
pub fn into_h(self) -> Result<H, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_i(i: I) -> Result<Self, I>
pub fn new_i(i: I) -> Result<Self, I>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_i(self) -> Result<I, Self>
pub fn into_i(self) -> Result<I, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_j(j: J) -> Result<Self, J>
pub fn new_j(j: J) -> Result<Self, J>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_j(self) -> Result<J, Self>
pub fn into_j(self) -> Result<J, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_k(k: K) -> Result<Self, K>
pub fn new_k(k: K) -> Result<Self, K>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_k(self) -> Result<K, Self>
pub fn into_k(self) -> Result<K, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_l(l: L) -> Result<Self, L>
pub fn new_l(l: L) -> Result<Self, L>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_l(self) -> Result<L, Self>
pub fn into_l(self) -> Result<L, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_m(m: M) -> Result<Self, M>
pub fn new_m(m: M) -> Result<Self, M>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_m(self) -> Result<M, Self>
pub fn into_m(self) -> Result<M, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_n(n: N) -> Result<Self, N>
pub fn new_n(n: N) -> Result<Self, N>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_n(self) -> Result<N, Self>
pub fn into_n(self) -> Result<N, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_o(o: O) -> Result<Self, O>
pub fn new_o(o: O) -> Result<Self, O>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_o(self) -> Result<O, Self>
pub fn into_o(self) -> Result<O, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn new_p(p: P) -> Result<Self, P>
pub fn new_p(p: P) -> Result<Self, P>
Construct a varaint of this union with a dynamic alignment check.
sourcepub fn into_p(self) -> Result<P, Self>
pub fn into_p(self) -> Result<P, Self>
Extract this variant from the union.
Returns the union on error.
sourcepub fn unpack(self) -> Enum16<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>
pub fn unpack(self) -> Enum16<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>
Unpack this union into an enum.
sourcepub fn ptr_eq(&self, other: &Self) -> bool
pub fn ptr_eq(&self, other: &Self) -> bool
Check if two unions are the same variant and point to the same value (not that the values compare as equal).
sourcepub fn as_deref<'a>(
&'a self,
builder: Builder16<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target, &'a I::Target, &'a J::Target, &'a K::Target, &'a L::Target, &'a M::Target, &'a N::Target, &'a O::Target, &'a P::Target>
) -> Union16<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target, &'a I::Target, &'a J::Target, &'a K::Target, &'a L::Target, &'a M::Target, &'a N::Target, &'a O::Target, &'a P::Target>where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: Deref,
I: Deref,
J: Deref,
K: Deref,
L: Deref,
M: Deref,
N: Deref,
O: Deref,
P: Deref,
&'a A::Target: ErasablePtr,
&'a B::Target: ErasablePtr,
&'a C::Target: ErasablePtr,
&'a D::Target: ErasablePtr,
&'a E::Target: ErasablePtr,
&'a F::Target: ErasablePtr,
&'a G::Target: ErasablePtr,
&'a H::Target: ErasablePtr,
&'a I::Target: ErasablePtr,
&'a J::Target: ErasablePtr,
&'a K::Target: ErasablePtr,
&'a L::Target: ErasablePtr,
&'a M::Target: ErasablePtr,
&'a N::Target: ErasablePtr,
&'a O::Target: ErasablePtr,
&'a P::Target: ErasablePtr,
pub fn as_deref<'a>(
&'a self,
builder: Builder16<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target, &'a I::Target, &'a J::Target, &'a K::Target, &'a L::Target, &'a M::Target, &'a N::Target, &'a O::Target, &'a P::Target>
) -> Union16<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target, &'a I::Target, &'a J::Target, &'a K::Target, &'a L::Target, &'a M::Target, &'a N::Target, &'a O::Target, &'a P::Target>where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: Deref,
I: Deref,
J: Deref,
K: Deref,
L: Deref,
M: Deref,
N: Deref,
O: Deref,
P: Deref,
&'a A::Target: ErasablePtr,
&'a B::Target: ErasablePtr,
&'a C::Target: ErasablePtr,
&'a D::Target: ErasablePtr,
&'a E::Target: ErasablePtr,
&'a F::Target: ErasablePtr,
&'a G::Target: ErasablePtr,
&'a H::Target: ErasablePtr,
&'a I::Target: ErasablePtr,
&'a J::Target: ErasablePtr,
&'a K::Target: ErasablePtr,
&'a L::Target: ErasablePtr,
&'a M::Target: ErasablePtr,
&'a N::Target: ErasablePtr,
&'a O::Target: ErasablePtr,
&'a P::Target: ErasablePtr,
Dereference the current pointer.
sourcepub unsafe fn as_deref_unchecked<'a>(
&'a self
) -> Union16<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target, &'a I::Target, &'a J::Target, &'a K::Target, &'a L::Target, &'a M::Target, &'a N::Target, &'a O::Target, &'a P::Target>where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: Deref,
I: Deref,
J: Deref,
K: Deref,
L: Deref,
M: Deref,
N: Deref,
O: Deref,
P: Deref,
&'a A::Target: ErasablePtr,
&'a B::Target: ErasablePtr,
&'a C::Target: ErasablePtr,
&'a D::Target: ErasablePtr,
&'a E::Target: ErasablePtr,
&'a F::Target: ErasablePtr,
&'a G::Target: ErasablePtr,
&'a H::Target: ErasablePtr,
&'a I::Target: ErasablePtr,
&'a J::Target: ErasablePtr,
&'a K::Target: ErasablePtr,
&'a L::Target: ErasablePtr,
&'a M::Target: ErasablePtr,
&'a N::Target: ErasablePtr,
&'a O::Target: ErasablePtr,
&'a P::Target: ErasablePtr,
pub unsafe fn as_deref_unchecked<'a>(
&'a self
) -> Union16<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target, &'a I::Target, &'a J::Target, &'a K::Target, &'a L::Target, &'a M::Target, &'a N::Target, &'a O::Target, &'a P::Target>where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: Deref,
I: Deref,
J: Deref,
K: Deref,
L: Deref,
M: Deref,
N: Deref,
O: Deref,
P: Deref,
&'a A::Target: ErasablePtr,
&'a B::Target: ErasablePtr,
&'a C::Target: ErasablePtr,
&'a D::Target: ErasablePtr,
&'a E::Target: ErasablePtr,
&'a F::Target: ErasablePtr,
&'a G::Target: ErasablePtr,
&'a H::Target: ErasablePtr,
&'a I::Target: ErasablePtr,
&'a J::Target: ErasablePtr,
&'a K::Target: ErasablePtr,
&'a L::Target: ErasablePtr,
&'a M::Target: ErasablePtr,
&'a N::Target: ErasablePtr,
&'a O::Target: ErasablePtr,
&'a P::Target: ErasablePtr,
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.
sourcepub fn as_untagged_ptr(&self) -> ErasedPtr
pub fn as_untagged_ptr(&self) -> ErasedPtr
Get the raw type-erased untagged pointer to the payload.
sourcepub fn try_deref<'a>(
&'a self
) -> Option<Union16<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target, &'a I::Target, &'a J::Target, &'a K::Target, &'a L::Target, &'a M::Target, &'a N::Target, &'a O::Target, &'a P::Target>>where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: Deref,
I: Deref,
J: Deref,
K: Deref,
L: Deref,
M: Deref,
N: Deref,
O: Deref,
P: Deref,
&'a A::Target: ErasablePtr,
&'a B::Target: ErasablePtr,
&'a C::Target: ErasablePtr,
&'a D::Target: ErasablePtr,
&'a E::Target: ErasablePtr,
&'a F::Target: ErasablePtr,
&'a G::Target: ErasablePtr,
&'a H::Target: ErasablePtr,
&'a I::Target: ErasablePtr,
&'a J::Target: ErasablePtr,
&'a K::Target: ErasablePtr,
&'a L::Target: ErasablePtr,
&'a M::Target: ErasablePtr,
&'a N::Target: ErasablePtr,
&'a O::Target: ErasablePtr,
&'a P::Target: ErasablePtr,
pub fn try_deref<'a>(
&'a self
) -> Option<Union16<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target, &'a I::Target, &'a J::Target, &'a K::Target, &'a L::Target, &'a M::Target, &'a N::Target, &'a O::Target, &'a P::Target>>where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: Deref,
I: Deref,
J: Deref,
K: Deref,
L: Deref,
M: Deref,
N: Deref,
O: Deref,
P: Deref,
&'a A::Target: ErasablePtr,
&'a B::Target: ErasablePtr,
&'a C::Target: ErasablePtr,
&'a D::Target: ErasablePtr,
&'a E::Target: ErasablePtr,
&'a F::Target: ErasablePtr,
&'a G::Target: ErasablePtr,
&'a H::Target: ErasablePtr,
&'a I::Target: ErasablePtr,
&'a J::Target: ErasablePtr,
&'a K::Target: ErasablePtr,
&'a L::Target: ErasablePtr,
&'a M::Target: ErasablePtr,
&'a N::Target: ErasablePtr,
&'a O::Target: ErasablePtr,
&'a P::Target: ErasablePtr,
Dereference the current pointer.
Performs a dynamic alignment check on the dereferenced pointer.