pub struct Union8<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr = NeverPtr, G: ErasablePtr = NeverPtr, H: ErasablePtr = NeverPtr> { /* private fields */ }
Expand description
A pointer union of eight pointer types.
This is a tagged union of eight 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 u64
(align(8)
).
This is enforced through the use of Builder8
.
Pointers beyond the fifth 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
sourceimpl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Union8<A, B, C, D, E, F, G, H>
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Union8<A, B, C, D, E, F, G, H>
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 a(&self) -> Option<&A::Target> where
A: Deref,
pub fn a(&self) -> Option<&A::Target> where
A: Deref,
Get a reference to this variant’s target.
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 b(&self) -> Option<&B::Target> where
B: Deref,
pub fn b(&self) -> Option<&B::Target> where
B: Deref,
Get a reference to this variant’s target.
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 c(&self) -> Option<&C::Target> where
C: Deref,
pub fn c(&self) -> Option<&C::Target> where
C: Deref,
Get a reference to this variant’s target.
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 d(&self) -> Option<&D::Target> where
D: Deref,
pub fn d(&self) -> Option<&D::Target> where
D: Deref,
Get a reference to this variant’s target.
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 e(&self) -> Option<&E::Target> where
E: Deref,
pub fn e(&self) -> Option<&E::Target> where
E: Deref,
Get a reference to this variant’s target.
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 f(&self) -> Option<&F::Target> where
F: Deref,
pub fn f(&self) -> Option<&F::Target> where
F: Deref,
Get a reference to this variant’s target.
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 g(&self) -> Option<&G::Target> where
G: Deref,
pub fn g(&self) -> Option<&G::Target> where
G: Deref,
Get a reference to this variant’s target.
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 h(&self) -> Option<&H::Target> where
H: Deref,
pub fn h(&self) -> Option<&H::Target> where
H: Deref,
Get a reference to this variant’s target.
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: Builder8<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target>
) -> Union8<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target> where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: 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,
pub fn as_deref<'a>(
&'a self,
builder: Builder8<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target>
) -> Union8<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target> where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: 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,
Dereference the current pointer.
sourcepub unsafe fn as_deref_unchecked<'a>(
&'a self
) -> Union8<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target> where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: 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,
pub unsafe fn as_deref_unchecked<'a>(
&'a self
) -> Union8<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target> where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: 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,
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<Union8<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target>> where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: 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,
pub fn try_deref<'a>(
&'a self
) -> Option<Union8<&'a A::Target, &'a B::Target, &'a C::Target, &'a D::Target, &'a E::Target, &'a F::Target, &'a G::Target, &'a H::Target>> where
A: Deref,
B: Deref,
C: Deref,
D: Deref,
E: Deref,
F: Deref,
G: Deref,
H: 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,
Dereference the current pointer.
Performs a dynamic alignment check on the dereferenced pointer.
Trait Implementations
sourceimpl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Clone for Union8<A, B, C, D, E, F, G, H> where
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
F: Clone,
G: Clone,
H: Clone,
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Clone for Union8<A, B, C, D, E, F, G, H> where
A: Clone,
B: Clone,
C: Clone,
D: Clone,
E: Clone,
F: Clone,
G: Clone,
H: Clone,
sourceimpl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Debug for Union8<A, B, C, D, E, F, G, H> where
A: Debug,
B: Debug,
C: Debug,
D: Debug,
E: Debug,
F: Debug,
G: Debug,
H: Debug,
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Debug for Union8<A, B, C, D, E, F, G, H> where
A: Debug,
B: Debug,
C: Debug,
D: Debug,
E: Debug,
F: Debug,
G: Debug,
H: Debug,
sourceimpl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Drop for Union8<A, B, C, D, E, F, G, H>
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Drop for Union8<A, B, C, D, E, F, G, H>
sourceimpl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> ErasablePtr for Union8<A, B, C, D, E, F, G, H>
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> ErasablePtr for Union8<A, B, C, D, E, F, G, H>
sourceimpl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Hash for Union8<A, B, C, D, E, F, G, H> where
A: Hash,
B: Hash,
C: Hash,
D: Hash,
E: Hash,
F: Hash,
G: Hash,
H: Hash,
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Hash for Union8<A, B, C, D, E, F, G, H> where
A: Hash,
B: Hash,
C: Hash,
D: Hash,
E: Hash,
F: Hash,
G: Hash,
H: Hash,
sourceimpl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> PartialEq<Union8<A, B, C, D, E, F, G, H>> for Union8<A, B, C, D, E, F, G, H> where
A: PartialEq,
B: PartialEq,
C: PartialEq,
D: PartialEq,
E: PartialEq,
F: PartialEq,
G: PartialEq,
H: PartialEq,
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> PartialEq<Union8<A, B, C, D, E, F, G, H>> for Union8<A, B, C, D, E, F, G, H> where
A: PartialEq,
B: PartialEq,
C: PartialEq,
D: PartialEq,
E: PartialEq,
F: PartialEq,
G: PartialEq,
H: PartialEq,
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Eq for Union8<A, B, C, D, E, F, G, H> where
A: Eq,
B: Eq,
C: Eq,
D: Eq,
E: Eq,
F: Eq,
G: Eq,
H: Eq,
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Send for Union8<A, B, C, D, E, F, G, H> where
A: Send,
B: Send,
C: Send,
D: Send,
E: Send,
F: Send,
G: Send,
H: Send,
impl<A: ErasablePtr, B: ErasablePtr, C: ErasablePtr, D: ErasablePtr, E: ErasablePtr, F: ErasablePtr, G: ErasablePtr, H: ErasablePtr> Sync for Union8<A, B, C, D, E, F, G, H> where
A: Sync,
B: Sync,
C: Sync,
D: Sync,
E: Sync,
F: Sync,
G: Sync,
H: Sync,
Auto Trait Implementations
impl<A, B, C, D, E, F, G, H> RefUnwindSafe for Union8<A, B, C, D, E, F, G, H> where
A: RefUnwindSafe,
B: RefUnwindSafe,
C: RefUnwindSafe,
D: RefUnwindSafe,
E: RefUnwindSafe,
F: RefUnwindSafe,
G: RefUnwindSafe,
H: RefUnwindSafe,
impl<A, B, C, D, E, F, G, H> Unpin for Union8<A, B, C, D, E, F, G, H> where
A: Unpin,
B: Unpin,
C: Unpin,
D: Unpin,
E: Unpin,
F: Unpin,
G: Unpin,
H: Unpin,
impl<A, B, C, D, E, F, G, H> UnwindSafe for Union8<A, B, C, D, E, F, G, H> where
A: UnwindSafe,
B: UnwindSafe,
C: UnwindSafe,
D: UnwindSafe,
E: UnwindSafe,
F: UnwindSafe,
G: UnwindSafe,
H: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Erasable for T
impl<T> Erasable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more