[−][src]Struct elysees::ArcBox
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.
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. You can also attempt to cast an Arc back into a ArcBox, which will
succeed if the Arc is unique
let data = [1, 2, 3, 4, 5]; let mut x = ArcBox::new(data); let x_ptr = x.deref() as *const _; x[4] = 7; // mutate! // The allocation has been modified, but not moved assert_eq!(x.deref(), &[1, 2, 3, 4, 7]); assert_eq!(x_ptr, x.deref() as *const _); let y = x.shareable(); // y is an Arc<T> // The allocation has not been modified or moved assert_eq!(y.deref(), &[1, 2, 3, 4, 7]); assert_eq!(x_ptr, y.deref() as *const _);
Implementations
impl<T> ArcBox<T>[src]
impl<T: ?Sized> ArcBox<T>[src]
Trait Implementations
impl<S: ?Sized + SliceDst> AllocSliceDst<S> for ArcBox<S>[src]
unsafe fn new_slice_dst<I>(len: usize, init: I) -> Self where
I: FnOnce(NonNull<S>), [src]
I: FnOnce(NonNull<S>),
impl<T: ?Sized> AsMut<T> for ArcBox<T>[src]
impl<T: ?Sized> AsRef<*const T> for ArcBox<T>[src]
impl<T: ?Sized> AsRef<*mut T> for ArcBox<T>[src]
impl<T: ?Sized> AsRef<NonNull<T>> for ArcBox<T>[src]
impl<T: ?Sized> AsRef<T> for ArcBox<T>[src]
impl<T: ?Sized> Borrow<T> for ArcBox<T>[src]
impl<T: ?Sized> BorrowMut<T> for ArcBox<T>[src]
fn borrow_mut(&mut self) -> &mut T[src]
impl<T: Clone> Clone for ArcBox<T>[src]
impl<T: Debug + ?Sized> Debug for ArcBox<T>[src]
impl<T: Default> Default for ArcBox<T>[src]
impl<T: ?Sized> Deref for ArcBox<T>[src]
impl<T: ?Sized> DerefMut for ArcBox<T>[src]
impl<T: Eq + ?Sized> Eq for ArcBox<T>[src]
impl<T: ?Sized + Erasable> ErasablePtr for ArcBox<T>[src]
impl<T: Hash + ?Sized> Hash for ArcBox<T>[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<T: Ord + ?Sized> Ord for ArcBox<T>[src]
fn cmp(&self, other: &ArcBox<T>) -> Ordering[src]
#[must_use]fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self[src]
impl<T: PartialEq + ?Sized> PartialEq<ArcBox<T>> for ArcBox<T>[src]
impl<T: PartialOrd + ?Sized> PartialOrd<ArcBox<T>> for ArcBox<T>[src]
fn partial_cmp(&self, other: &ArcBox<T>) -> Option<Ordering>[src]
fn lt(&self, other: &ArcBox<T>) -> bool[src]
fn le(&self, other: &ArcBox<T>) -> bool[src]
fn gt(&self, other: &ArcBox<T>) -> bool[src]
fn ge(&self, other: &ArcBox<T>) -> bool[src]
impl<T: ?Sized> StableDeref for ArcBox<T>[src]
impl<T> Stowable for ArcBox<T>[src]
impl<T: ?Sized> StructuralEq for ArcBox<T>[src]
impl<T: ?Sized> StructuralPartialEq for ArcBox<T>[src]
impl<S: ?Sized + SliceDst> TryAllocSliceDst<S> for ArcBox<S>[src]
unsafe fn try_new_slice_dst<I, E>(len: usize, init: I) -> Result<Self, E> where
I: FnOnce(NonNull<S>) -> Result<(), E>, [src]
I: FnOnce(NonNull<S>) -> Result<(), E>,
impl<T: ?Sized> UnionAlign for ArcBox<T> where
ArcBox<T>: ErasablePtr, [src]
ArcBox<T>: ErasablePtr,
fn left<B: UnionAlign>(this: Self) -> Union2<Self, B>[src]
fn right<A: UnionAlign>(this: Self) -> Union2<A, Self>[src]
fn a<B: UnionAlign, C: UnionAlign, D: UnionAlign>(
this: Self
) -> Union4<Self, B, C, D>[src]
this: Self
) -> Union4<Self, B, C, D>
fn b<A: UnionAlign, C: UnionAlign, D: UnionAlign>(
this: Self
) -> Union4<A, Self, C, D>[src]
this: Self
) -> Union4<A, Self, C, D>
fn c<A: UnionAlign, B: UnionAlign, D: UnionAlign>(
this: Self
) -> Union4<A, B, Self, D>[src]
this: Self
) -> Union4<A, B, Self, D>
fn d<A: UnionAlign, B: UnionAlign, C: UnionAlign>(
this: Self
) -> Union4<A, B, C, Self>[src]
this: Self
) -> Union4<A, B, C, Self>
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for ArcBox<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T: ?Sized> Send for ArcBox<T> where
T: Send + Sync,
T: Send + Sync,
impl<T: ?Sized> Sync for ArcBox<T> where
T: Send + Sync,
T: Send + Sync,
impl<T: ?Sized> Unpin for ArcBox<T> where
T: Unpin,
T: Unpin,
impl<T: ?Sized> UnwindSafe for ArcBox<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,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Erasable for T[src]
unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>[src]
const ACK_1_1_0: bool[src]
fn erase(this: NonNull<Self>) -> NonNull<Erased>[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> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
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.
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>,