Struct elysees::ArcBox [−][src]
#[repr(transparent)]pub struct ArcBox<T: ?Sized>(_);
Expand description
An Arc
that is known to be uniquely owned
When Arc
s are constructed, they are known to be
uniquely owned. In such a case it is safe to mutate
the contents of the Arc
. Normally, one would just handle
this by mutating the data on the stack before allocating the
Arc
, however it’s possible the data is large or unsized
and you need to heap-allocate it earlier in such a way
that it can be freely converted into a regular Arc
once you’re
done.
ArcBox
exists for this purpose, when constructed it performs
the same allocations necessary for an Arc
, however it allows mutable access.
Once the mutation is finished, you can call .shareable()
and get a regular Arc
out of it.
let data = [1, 2, 3, 4, 5];
let mut x = ArcBox::new(data);
x[4] = 7; // mutate!
let y = x.shareable(); // y is an Arc<T>
Implementations
Convert to an initialized Arc
.
Safety
This function is equivalent to MaybeUninit::assume_init
and has the
same safety requirements. You are responsible for ensuring that the T
has actually been initialized before calling this method.
Trait Implementations
Mutably borrows from an owned value. Read more
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for ArcBox<T> where
T: RefUnwindSafe,
impl<T: ?Sized> UnwindSafe for ArcBox<T> where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more