[][src]Struct heaparray::base::ThinPtrArray

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

Heap-allocated array, with array size stored alongside the memory block itself.

Examples

Creating an array:

use heaparray::base::*;
let len = 10;
let array = ThinPtrArray::new(len, |idx| idx + 3);

Indexing works as you would expect:

array[3] = 2;
assert!(array[3] == 2);

Additionally, you can customize what information should be stored alongside the elements in the array using the ThinPtrArray::with_label function:

struct MyLabel {
    pub even: usize,
    pub odd: usize,
}

let mut array = ThinPtrArray::with_label(
    MyLabel { even: 0, odd: 0 },
    100,
    |label, index| {
        if index % 2 == 0 {
            label.even += 1;
            index
        } else {
            label.odd += 1;
            index
        }
    });

Trait Implementations

impl<E, L> BaseArrayRef for ThinPtrArray<E, L>[src]

impl<E, L> LabelledArray<E, L> for ThinPtrArray<E, L>[src]

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

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

impl<E> MakeArray<E> for ThinPtrArray<E, ()>[src]

impl<E, L> SliceArray<E> for ThinPtrArray<E, L>[src]

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

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

impl<E, L> IntoIterator for ThinPtrArray<E, L>[src]

type Item = E

The type of the elements being iterated over.

type IntoIter = ThinPtrArrayIter<E, L>

Which kind of iterator are we turning this into?

impl<'b, E, L> IntoIterator for &'b ThinPtrArray<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 ThinPtrArray<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> Sync for ThinPtrArray<E, L> where
    E: Sync,
    L: Sync
[src]

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

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

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

type Output = E

The returned type after indexing.

impl<E, L> IndexMut<usize> for ThinPtrArray<E, L>[src]

impl<E, L> Container for ThinPtrArray<E, L>[src]

impl<E, L> CopyMap<usize, E> for ThinPtrArray<E, L>[src]

Blanket Implementations

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> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]