[−][src]Struct ngen::arena::TempArena
A temporary memory arena.
Implementations
impl TempArena
[src]
pub fn with_capacity(capacity: usize) -> Result<Self, String>
[src]
Creates a temporary memory arena with a given capacity, returning an error if it is unable to allocate the full amount of memory.
Example
let arena = TempArena::with_capacity(1024).unwrap();
pub fn len(&self) -> usize
[src]
Returns the total amount of memory used since the last reset.
Example
let mut arena = TempArena::with_capacity(1024).unwrap(); arena.push(4.0f32); assert_eq!(arena.len(), std::mem::size_of::<f32>());
pub fn push_default<'a, T: Default>(&'a self) -> &'a mut T
[src]
Pushes a default value for a given T
into the temp arena, using the correct alignment for the pushed value.
Example
let mut arena = TempArena::with_capacity(1024).unwrap(); let forty_two = arena.push_default::<i32>(); assert_eq!(forty_two, &0);
pub fn push<'a, T>(&'a self, default: T) -> &'a mut T
[src]
Pushes a new value into the temp arena, using the correct alignment for the pushed value.
Example
let mut arena = TempArena::with_capacity(1024).unwrap(); let forty_two = arena.push(42); assert_eq!(forty_two, &42);
pub fn reset(&mut self)
[src]
Resets the current memory arena, pointing the current location to the start of the allocated memory.
Example
let mut arena = TempArena::with_capacity(1024).unwrap(); // Push some items into the arena. for i in 0..42 { arena.push(i); } assert_eq!(arena.len(), std::mem::size_of::<i32>() * 42); arena.reset(); assert_eq!(arena.len(), 0);
pub fn array<T>(&mut self) -> Array<'_, T>
[src]
Returns exclusive access to the memory arena to create a contiguous, and growable, array of items.
Example
let mut arena = TempArena::with_capacity(1024).unwrap(); let mut array = arena.array(); array.push(42);
Auto Trait Implementations
impl !RefUnwindSafe for TempArena
impl Send for TempArena
impl !Sync for TempArena
impl Unpin for TempArena
impl UnwindSafe for TempArena
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>,