[−][src]Struct heaparray::HeapArray
Heap-allocated array, with array size stored with the pointer to the memory.
Examples
Creating an array:
use heaparray::base::*; let len = 10; let array = FatPtrArray::new(len, |idx| idx + 3);
Indexing works as you would expect:
array[3] = 2; assert!(array[3] == 2);
Notably, you can take ownership of objects back from the container:
let mut array = FatPtrArray::new(10, |_| Vec::<u8>::new()); let replacement_object = Vec::new(); let owned_object = array.insert(0, replacement_object);
but you need to give the array a replacement object to fill its slot with.
Additionally, you can customize what information should be stored alongside the elements in
the array using the FatPtrArray::with_label
function:
struct MyLabel { pub even: usize, pub odd: usize, } let mut array = FatPtrArray::with_label( MyLabel { even: 0, odd: 0 }, 100, |label, index| { if index % 2 == 0 { label.even += 1; index } else { label.odd += 1; index } });
Invariants
This struct follows the same invariants as mentioned in heaparray::mem_block
,
and does not check for pointer validity; you should use this struct in the same
way you would use a raw array or slice.
Trait Implementations
impl<E, L> BaseArrayRef for FatPtrArray<E, L>
[src]
impl<E, L> LabelledArray<E, L> for FatPtrArray<E, L>
[src]
fn with_label<F>(label: L, len: usize, func: F) -> Self where
F: FnMut(&mut L, usize) -> E,
[src]
F: FnMut(&mut L, usize) -> E,
unsafe fn with_label_unsafe(label: L, len: usize) -> Self
[src]
fn get_label(&self) -> &L
[src]
unsafe fn get_label_unsafe(&self) -> &mut L
[src]
unsafe fn get_unsafe(&self, idx: usize) -> &mut E
[src]
impl<E, L> LabelledArrayMut<E, L> for FatPtrArray<E, L>
[src]
fn get_label_mut(&mut self) -> &mut L
[src]
impl<E, L> DefaultLabelledArray<E, L> for FatPtrArray<E, L> where
E: Default,
[src]
E: Default,
impl<E> MakeArray<E> for FatPtrArray<E, ()>
[src]
impl<E, L> SliceArray<E> for FatPtrArray<E, L>
[src]
impl<E, L> Sync for FatPtrArray<E, L> where
E: Sync,
L: Sync,
[src]
E: Sync,
L: Sync,
impl<E, L> Clone for FatPtrArray<E, L> where
E: Clone,
L: Clone,
[src]
E: Clone,
L: Clone,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
[src]
impl<E, L> Drop for FatPtrArray<E, L>
[src]
impl<E, L> Send for FatPtrArray<E, L> where
E: Send,
L: Send,
[src]
E: Send,
L: Send,
impl<E, L> IntoIterator for FatPtrArray<E, L>
[src]
type Item = E
The type of the elements being iterated over.
type IntoIter = FatPtrArrayIter<E, L>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'b, E, L> IntoIterator for &'b FatPtrArray<E, L>
[src]
type Item = &'b E
The type of the elements being iterated over.
type IntoIter = Iter<'b, E>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'b, E, L> IntoIterator for &'b mut FatPtrArray<E, L>
[src]
type Item = &'b mut E
The type of the elements being iterated over.
type IntoIter = IterMut<'b, E>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<E, L> Debug for FatPtrArray<E, L> where
E: Debug,
L: Debug,
[src]
E: Debug,
L: Debug,
impl<E, L> Index<usize> for FatPtrArray<E, L>
[src]
impl<E, L> IndexMut<usize> for FatPtrArray<E, L>
[src]
impl<E, L> Container for FatPtrArray<E, L>
[src]
impl<E, L> CopyMap<usize, E> for FatPtrArray<E, L>
[src]
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,