Struct elysees::ArcBox[][src]

#[repr(transparent)]
pub struct ArcBox<T: ?Sized>(_);
Expand description

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.

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

Construct a new ArcBox

Construct an uninitialized ArcBox

Gets the inner value of this ArcBox

Convert to a shareable [ArcRef<'static, T>] once we’re done mutating it

Convert to a shareable Arc<T> once we’re done mutating it

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

Performs the conversion.

Performs the conversion.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The type we point to. This influences which kinds of unsizing are possible. Read more

The output type when unsizing the pointee to U.

Get the raw inner pointer.

Replace the container inner pointer with an unsized version. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert a pointer, as if with unsize coercion. Read more

Unerase this erased pointer. Read more

Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more

Turn this erasable pointer into an erased pointer. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.