[][src]Struct triomphe::ArcUnion

pub struct ArcUnion<A, B> { /* fields omitted */ }

A tagged union that can represent Arc<A> or Arc<B> while only consuming a single word. The type is also NonNull, and thus can be stored in an Option without increasing size.

This is functionally equivalent to enum ArcUnion<A, B> { First(Arc<A>), Second(Arc<B>) but only takes up up a single word of stack space.

This could probably be extended to support four types if necessary.

Implementations

impl<A, B> ArcUnion<A, B>[src]

pub fn ptr_eq(this: &Self, other: &Self) -> bool[src]

Returns true if the two values are pointer-equal.

pub fn borrow(&self) -> ArcUnionBorrow<'_, A, B>[src]

Returns an enum representing a borrow of either A or B.

pub fn from_first(other: Arc<A>) -> Self[src]

Creates an ArcUnion from an instance of the first type.

pub fn from_second(other: Arc<B>) -> Self[src]

Creates an ArcUnion from an instance of the second type.

pub fn is_first(&self) -> bool[src]

Returns true if this ArcUnion contains the first type.

pub fn is_second(&self) -> bool[src]

Returns true if this ArcUnion contains the second type.

pub fn as_first(&self) -> Option<ArcBorrow<'_, A>>[src]

Returns a borrow of the first type if applicable, otherwise None.

pub fn as_second(&self) -> Option<ArcBorrow<'_, B>>[src]

Returns a borrow of the second type if applicable, otherwise None.

Trait Implementations

impl<A, B> Clone for ArcUnion<A, B>[src]

impl<A: Debug, B: Debug> Debug for ArcUnion<A, B>[src]

impl<A, B> Drop for ArcUnion<A, B>[src]

impl<A: PartialEq, B: PartialEq> PartialEq<ArcUnion<A, B>> for ArcUnion<A, B>[src]

impl<A: Sync + Send, B: Send + Sync> Send for ArcUnion<A, B>[src]

impl<A: Sync + Send, B: Send + Sync> Sync for ArcUnion<A, B>[src]

Auto Trait Implementations

impl<A, B> RefUnwindSafe for ArcUnion<A, B> where
    A: RefUnwindSafe,
    B: RefUnwindSafe
[src]

impl<A, B> Unpin for ArcUnion<A, B> where
    A: Unpin,
    B: Unpin
[src]

impl<A, B> UnwindSafe for ArcUnion<A, B> where
    A: UnwindSafe,
    B: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.