pub struct ArcUnion<A, B> { /* private fields */ }
Expand description
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
sourceimpl<A, B> ArcUnion<A, B>
impl<A, B> ArcUnion<A, B>
sourcepub fn ptr_eq(this: &Self, other: &Self) -> bool
pub fn ptr_eq(this: &Self, other: &Self) -> bool
Returns true if the two values are pointer-equal.
sourcepub fn borrow(&self) -> ArcUnionBorrow<'_, A, B>
pub fn borrow(&self) -> ArcUnionBorrow<'_, A, B>
Returns an enum representing a borrow of either A or B.
sourcepub fn from_first(other: Arc<A>) -> Self
pub fn from_first(other: Arc<A>) -> Self
Creates an ArcUnion
from an instance of the first type.
sourcepub fn from_second(other: Arc<B>) -> Self
pub fn from_second(other: Arc<B>) -> Self
Creates an ArcUnion
from an instance of the second type.
Trait Implementations
sourceimpl<A: PartialEq, B: PartialEq> PartialEq<ArcUnion<A, B>> for ArcUnion<A, B>
impl<A: PartialEq, B: PartialEq> PartialEq<ArcUnion<A, B>> for ArcUnion<A, B>
impl<A: Sync + Send, B: Send + Sync> Send for ArcUnion<A, B>
impl<A: Sync + Send, B: Send + Sync> Sync for ArcUnion<A, B>
Auto Trait Implementations
impl<A, B> RefUnwindSafe for ArcUnion<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Unpin for ArcUnion<A, B>where
A: Unpin,
B: Unpin,
impl<A, B> UnwindSafe for ArcUnion<A, B>where
A: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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