[−][src]Struct triomphe::ArcUnion
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,
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Unpin for ArcUnion<A, B> where
A: Unpin,
B: Unpin,
A: Unpin,
B: Unpin,
impl<A, B> UnwindSafe for ArcUnion<A, B> where
A: UnwindSafe,
B: UnwindSafe,
A: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,