Struct fdf::ArenaBox

source ·
pub struct ArenaBox<'a, T: ?Sized>(/* private fields */);
Expand description

Holds a reference to data of type T in an Arena with lifetime 'a, and ensures that the object is properly dropped before the Arena goes out of scope.

Implementations§

source§

impl<'a, T> ArenaBox<'a, T>

source

pub fn take(value: Self) -> T

Moves the inner value of this ArenaBox out to owned storage.

source

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>>

source

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>]>

source

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.

source

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]>

source

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>

source

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.

source

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.

source

pub fn leak(this: Self) -> &'a mut T

Consumes and leaks this ArenaBox, returning a mutable reference to its contents.

source§

impl<'a> ArenaBox<'a, [MaybeUninit<u8>]>

source

pub unsafe fn cast_unchecked<T>(this: Self) -> ArenaBox<'a, T>

Transforms the ArenaBox into an ArenaBox<T>.

§Safety

The caller is responsible for ensuring that the contents of this ArenaBox originated from a source with a properly allocated T with correct alignment

Trait Implementations§

source§

impl<'a, T: Debug + ?Sized> Debug for ArenaBox<'a, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: ?Sized> Deref for ArenaBox<'_, T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T: ?Sized> DerefMut for ArenaBox<'_, T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'a, T: ?Sized> Drop for ArenaBox<'a, T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a, T: 'a> IntoIterator for ArenaBox<'a, [T]>

§

type IntoIter = IntoIter<T, PhantomData<&'a Arena>>

Which kind of iterator are we turning this into?
§

type Item = T

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T> Send for ArenaBox<'a, T>
where T: Send + ?Sized,

SAFETY: ArenaBox impls Send and Sync if T impls them.

source§

impl<'a, T> Sync for ArenaBox<'a, T>
where T: Sync + ?Sized,

Auto Trait Implementations§

§

impl<'a, T> Freeze for ArenaBox<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for ArenaBox<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> Unpin for ArenaBox<'a, T>
where T: ?Sized,

§

impl<'a, T> UnwindSafe for ArenaBox<'a, T>
where T: RefUnwindSafe + ?Sized,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.