[−][src]Struct ngen::arena::array::Array
A growable array of elements for a temporary memory arena.
Implementations
impl<'t, T> Array<'t, T>
[src]
pub fn new(arena: &'t mut TempArena) -> Self
[src]
Creates a new array, using the supplied temporary arena allocator as its backing store.
Example
let mut arena = TempArena::with_capacity(1024).unwrap(); let array = Array::<u32>::new(&mut arena);
Note
Instead of creating the array manually, it is easier to use the array
method of the
TempArena
.
let mut arena = TempArena::with_capacity(1024).unwrap(); let array = arena.array::<u32>();
Note
Arrays can be indexed, just like other collections in Rust.
let mut arena = TempArena::with_capacity(1024).unwrap(); let mut array = arena.array(); array.push(0); array.push(1); array.push(2); assert_eq!(array[1], 1); array[0] = 42; assert_eq!(array[0], 42);
pub fn push(&mut self, value: T)
[src]
Pushes a new element onto the end of the array.
Example
let mut arena = TempArena::with_capacity(1024).unwrap(); let mut array = arena.array(); array.push(7); array.push(42);
pub const fn len(&self) -> usize
[src]
Returns the current length of the array.
Example
let mut arena = TempArena::with_capacity(1024).unwrap(); let mut array = arena.array(); array.push(7); array.push(42); assert_eq!(array.len(), 2);
pub fn end(self) -> &'t mut [T]
[src]
Ends the array, returning a slice that points to the array's elements. This is important because it returns access to the temp arena to the rest of the application.
Example
let mut arena = TempArena::with_capacity(1024).unwrap(); let mut array = arena.array(); for i in 0..42 { array.push(i); } for (c, i) in array.end().iter().enumerate() { assert_eq!(*i, c as i32); }
Trait Implementations
impl<'t, T> Index<usize> for Array<'t, T>
[src]
type Output = T
The returned type after indexing.
fn index(&self, index: usize) -> &Self::Output
[src]
impl<'t, T> IndexMut<usize> for Array<'t, T>
[src]
Auto Trait Implementations
impl<'t, T> !RefUnwindSafe for Array<'t, T>
impl<'t, T> Send for Array<'t, T> where
T: Send,
T: Send,
impl<'t, T> !Sync for Array<'t, T>
impl<'t, T> Unpin for Array<'t, T> where
T: Unpin,
T: Unpin,
impl<'t, T> !UnwindSafe for Array<'t, T>
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>,