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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)