[−][src]Struct bump_into::BumpInto
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 alloc_space<S: Into<usize>, A: Into<usize>>(
&'this self,
size: S,
align: A
) -> *mut MaybeUninit<u8>
[src]
&'this self,
size: S,
align: A
) -> *mut MaybeUninit<u8>
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<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]
&'this self,
f: F
) -> Option<&'this mut T>
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]
&'this self,
count: usize,
iter: I
) -> Option<&'this mut [T]>
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.
Auto Trait Implementations
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,