[−][src]Struct triomphe::UniqueArc
An Arc that is known to be uniquely owned
When Arcs 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.
UniqueArc 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 = UniqueArc::new(data); x[4] = 7; // mutate! let y = x.shareable(); // y is an Arc<T>
Implementations
impl<T> UniqueArc<T>[src]
pub fn new(data: T) -> Self[src]
Construct a new UniqueArc
pub fn shareable(self) -> Arc<T>[src]
Convert to a shareable Arc
pub fn new_uninit() -> UniqueArc<MaybeUninit<T>>[src]
Construct an uninitialized arc
impl<T> UniqueArc<MaybeUninit<T>>[src]
pub unsafe fn assume_init(this: Self) -> UniqueArc<T>[src]
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
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for UniqueArc<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T: ?Sized> Send for UniqueArc<T> where
T: Send + Sync,
T: Send + Sync,
impl<T: ?Sized> Sync for UniqueArc<T> where
T: Send + Sync,
T: Send + Sync,
impl<T: ?Sized> Unpin for UniqueArc<T> where
T: Unpin,
T: Unpin,
impl<T: ?Sized> UnwindSafe for UniqueArc<T> where
T: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + 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,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,