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§
Source§impl<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 strong_count(this: &Self) -> usize
pub fn strong_count(this: &Self) -> usize
Reference count.
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§
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> Freeze for ArcUnion<A, B>
impl<A, B> RefUnwindSafe for ArcUnion<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Unpin for ArcUnion<A, B>
impl<A, B> UnwindSafe for ArcUnion<A, B>where
A: UnwindSafe,
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes