[][src]Struct bump_into::BumpInto

pub struct BumpInto<'a> { /* fields omitted */ }

A bump allocator over an arbitrary region of memory.

Methods

impl<'this, 'a: 'this> BumpInto<'a>[src]

pub fn new(array: &'a mut [MaybeUninit<u8>]) -> Self[src]

Creates a new BumpInto, wrapping a slice of MaybeUninit.

pub fn available_bytes(&'this self) -> usize[src]

Returns the number of bytes remaining in the allocator's space.

pub fn available_spaces<S: Into<usize>, A: Into<usize>>(
    &'this self,
    size: S,
    align: A
) -> usize
[src]

Returns the number of spaces of size size that could be allocated in a contiguous region ending at alignment align within the allocator's remaining space.

pub fn alloc_space<S: Into<usize>, A: Into<usize>>(
    &'this self,
    size: S,
    align: A
) -> *mut MaybeUninit<u8>
[src]

Tries to allocate size bytes with alignment align. Returns a null pointer on failure.

pub fn alloc_space_for<T>(&'this self) -> *mut T[src]

Tries to allocate enough space to store a T. Returns a properly aligned pointer to uninitialized T if there was enough space; otherwise returns a null pointer.

pub fn alloc_space_for_n<T>(&'this self, count: usize) -> *mut T[src]

Tries to allocate enough space to store count number of T. Returns a properly aligned pointer to uninitialized T if there was enough space; otherwise returns a null pointer.

pub fn alloc_space_to_limit_for<T>(&'this self) -> (NonNull<T>, usize)[src]

Allocates space for as many aligned T as will fit in the free space of this BumpInto. Returns a tuple holding a pointer to the lowest T-space that was just allocated and the count of T that will fit (which may be zero).

pub fn alloc<T>(&'this self, x: T) -> Result<&'this mut T, T>[src]

Tries to allocate enough space to store a T and place x there.

On success (i.e. if there was enough space) produces a mutable reference to x with the lifetime of this BumpInto.

On failure, produces x.

pub fn alloc_with<T, F: FnOnce() -> T>(
    &'this self,
    f: F
) -> Option<&'this mut T>
[src]

Tries to allocate enough space to store a T and place the result of calling f there.

On success (i.e. if there was enough space) produces a mutable reference to the stored result with the lifetime of this BumpInto.

pub fn alloc_n<T: Copy>(&'this self, xs: &[T]) -> Option<&'this mut [T]>[src]

Tries to allocate enough space to store a copy of xs and copy xs into it.

On success (i.e. if there was enough space) produces a mutable reference to the copy with the lifetime of this BumpInto.

pub fn alloc_n_with<T, I: IntoIterator<Item = T>>(
    &'this self,
    count: usize,
    iter: I
) -> Option<&'this mut [T]>
[src]

Tries to allocate enough space to store count number of T and fill it with the values produced by iter.into_iter().

On success (i.e. if there was enough space) produces a mutable reference to the stored results as a slice, with the lifetime of this BumpInto.

If the iterator ends before producing enough items to fill the allocated space, the same amount of space is allocated, but the returned slice is just long enough to hold the items that were actually produced.

pub fn alloc_down_with<T, I: IntoIterator<Item = T>>(
    &'this mut self,
    iter: I
) -> &'this mut [T]
[src]

Allocates enough space to store as many of the values produced by iter as possible. Produces a mutable reference to the stored results as a slice, in the opposite order to the order they were produced in, with the lifetime of this BumpInto.

pub unsafe fn alloc_down_with_shared<T, I: IntoIterator<Item = T>>(
    &'this self,
    iter: I
) -> &'this mut [T]
[src]

Unsafe version of alloc_down_with, taking self as a shared reference instead of a mutable reference.

Safety

Undefined behavior may result if any methods of this BumpInto are called from within the next method of the iterator, with the exception of the available_bytes and available_spaces methods, which are safe.

Trait Implementations

impl<'a> Debug for BumpInto<'a>[src]

Auto Trait Implementations

impl<'a> Send for BumpInto<'a>

impl<'a> !Sync for BumpInto<'a>

impl<'a> Unpin for BumpInto<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.