pub struct ArenaBox<'a, T: ?Sized>(/* private fields */);
Expand description
Implementations§
Source§impl<'a, T> ArenaBox<'a, T>
impl<'a, T> ArenaBox<'a, T>
Sourcepub fn take_boxed(value: Self) -> Box<T>
pub fn take_boxed(value: Self) -> Box<T>
Moves the inner value of this ArenaBox out into a Box
using the
global allocator. Using this instead of Box::new(ArenaBox::take(v))
helps to avoid any additional copies of the storage on its way to the
box.
Note: if you want to take a slice, you will need to use
Self::take_boxed_slice
.
Source§impl<'a, T> ArenaBox<'a, MaybeUninit<T>>
impl<'a, T> ArenaBox<'a, MaybeUninit<T>>
Sourcepub unsafe fn assume_init(self) -> ArenaBox<'a, T>
pub unsafe fn assume_init(self) -> ArenaBox<'a, T>
Assumes the contents of this MaybeUninit
box are initialized now.
§Safety
The caller is responsible for ensuring that the value is initialized
properly. See MaybeUninit::assume_init
for more details on the
safety requirements of this.
Source§impl<'a, T> ArenaBox<'a, [MaybeUninit<T>]>
impl<'a, T> ArenaBox<'a, [MaybeUninit<T>]>
Sourcepub unsafe fn assume_init_slice(self) -> ArenaBox<'a, [T]>
pub unsafe fn assume_init_slice(self) -> ArenaBox<'a, [T]>
Assumes the contents of this box of [MaybeUninit<T>]
are initialized now.
§Safety
The caller is responsible for ensuring that the value is initialized
properly. See MaybeUninit::assume_init
for more details on the
safety requirements of this.
Sourcepub unsafe fn assume_init_slice_len(self, len: usize) -> ArenaBox<'a, [T]>
pub unsafe fn assume_init_slice_len(self, len: usize) -> ArenaBox<'a, [T]>
Assumes the contents of this box of [MaybeUninit<T>]
are initialized now,
up to len
elements and ignores the rest.
§Safety
The caller is responsible for ensuring that the value is initialized
properly. See MaybeUninit::assume_init
for more details on the
safety requirements of this.
Source§impl<'a, T> ArenaBox<'a, [T]>
impl<'a, T> ArenaBox<'a, [T]>
Sourcepub fn take_boxed_slice(value: Self) -> Box<[T]>
pub fn take_boxed_slice(value: Self) -> Box<[T]>
Like Self::take_boxed
, this moves the inner value of this ArenaBox
out into a Box
using the global allocator, and using it avoids
additional copies of the data, but this function works on slices of T
,
which are unsized and so require special handling.
Source§impl<'a, T: ?Sized> ArenaBox<'a, T>
impl<'a, T: ?Sized> ArenaBox<'a, T>
Sourcepub unsafe fn into_ptr(value: Self) -> NonNull<T>
pub unsafe fn into_ptr(value: Self) -> NonNull<T>
Decomposes this ArenaBox
into its pointer.
§Safety
This is unsafe because it loses the lifetime of the Arena
it
came from. The caller must make sure to not let the pointer outlive the
arena. The caller is also responsible for making sure the object is
dropped before the Arena
, or it may leak resources.
Sourcepub unsafe fn erase_lifetime(value: Self) -> ArenaBox<'static, T>
pub unsafe fn erase_lifetime(value: Self) -> ArenaBox<'static, T>
Turns this ArenaBox
into one with the given lifetime.
§Safety
This is unsafe because it loses the lifetime of the Arena
it
came from. The caller must make sure to not let the
ArenaBox
outlive the Arena
it was created from. The caller
is also responsible for making sure the object is dropped before
the Arena
, or it may leak resources.