[][src]Struct heaparray::HeapArray

#[repr(C)]
pub struct HeapArray<E, L = ()> { /* fields omitted */ }

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]

impl<E, L> LabelledArrayMut<E, L> for FatPtrArray<E, L>[src]

impl<E, L> DefaultLabelledArray<E, L> for FatPtrArray<E, L> where
    E: Default
[src]

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]

impl<E, L> Send for FatPtrArray<E, L> where
    E: Send,
    L: Send
[src]

impl<E, L> Clone for FatPtrArray<E, L> where
    E: Clone,
    L: Clone
[src]

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?

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?

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?

impl<E, L> Drop for FatPtrArray<E, L>[src]

impl<E, L> Debug for FatPtrArray<E, L> where
    E: Debug,
    L: Debug
[src]

impl<E, L> Index<usize> for FatPtrArray<E, L>[src]

type Output = E

The returned type after indexing.

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

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.

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

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

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