[][src]Struct mop_structs::vec::VecArray

pub struct VecArray<A> { /* fields omitted */ }

A structure just like Vec, the difference is the inner storage provided by an array.

Methods

impl<A> VecArray<A> where
    A: Array
[src]

pub fn new(array: A, len: usize) -> Self[src]

Creates a new VecArray from a provided array and length.

Arguments

  • array - The array storage

Examples

use mop_structs::vec::VecArray;
let _ = VecArray::new([1, 2, 3, 4, 5], 2);

pub fn new_rnd<F, R>(len: usize, rng: &mut R, cb: F) -> Self where
    F: FnMut(&mut R, usize) -> A::Item,
    R: Rng
[src]

pub fn with_array(array: A) -> Self[src]

Creates a new VecArray from a provided array. Then length of Self will be the length of array.

Examples

use mop_structs::vec::VecArray;
let _ = VecArray::with_array([0; 10]);

pub fn with_capacity() -> Self[src]

Creates a new empty VecArray from an array type.

Examples

use mop_structs::vec::VecArray;
let _ = VecArray::<[i32; 10]>::with_capacity();

pub fn array(&self) -> &A[src]

pub fn len(&self) -> usize[src]

pub fn try_push(&mut self, item: A::Item) -> bool[src]

Trait Implementations

impl<A> DynDenseSto for VecArray<A> where
    A: Array
[src]

impl<A> DynDenseStoMut for VecArray<A> where
    A: Array
[src]

fn clear(&mut self)[src]

Examples

use mop_structs::{
    doc_tests::vec_array,
    prelude::*,
};
let mut a = vec_array();
a.clear();
assert_eq!(&a, &[]);

fn extend(&mut self, other: &[Self::Item]) where
    Self::Item: Copy
[src]

Examples

use mop_structs::{
    doc_tests::vec_array,
    prelude::*,
};
let mut a = vec_array();
a.extend(&[1, 2]);
assert_eq!(&a, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]);

fn extend_from_clone(&mut self, other: &[Self::Item]) where
    Self::Item: Clone
[src]

Examples

use mop_structs::{
    doc_tests::vec_array,
    prelude::*,
};
let mut a = vec_array();
a.extend_from_clone(&[1, 2]);
assert_eq!(&a, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]);

fn push(&mut self, item: A::Item)[src]

Examples

use mop_structs::{
    doc_tests::vec_array,
    prelude::*,
};
let mut a = vec_array();
a.push(100);
assert_eq!(&a, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100]);

fn swap(&mut self, a: usize, b: usize)[src]

Examples

use mop_structs::{
    doc_tests::vec_array,
    prelude::*,
};
let mut a = vec_array();
a.swap(0, 2);
assert_eq!(&a, &[3, 2, 1, 4, 5, 6, 7, 8, 9, 10]);

fn truncate(&mut self, idx: usize)[src]

Examples

use mop_structs::{
    doc_tests::vec_array,
    prelude::*,
};
let mut a = vec_array();
a.truncate(2);
assert_eq!(&a, &[1, 2]);

impl<A> DynDenseStoRef for VecArray<A> where
    A: Array
[src]

fn capacity(&self) -> usize[src]

Examples

use mop_structs::{
    doc_tests::vec_array,
    prelude::*,
};
assert_eq!(vec_array().capacity(), 16);

impl<A> StDenseStoMut for VecArray<A> where
    A: Array
[src]

fn as_mut_slice(&mut self) -> &mut [A::Item][src]

Examples

use mop_structs::{
    doc_tests::vec_array,
    prelude::*,
};
assert_eq!(vec_array().as_mut_slice(), &mut [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

impl<A> StDenseStoRef for VecArray<A> where
    A: Array
[src]

type Item = A::Item

fn as_slice(&self) -> &[A::Item][src]

Examples

use mop_structs::{
    doc_tests::vec_array,
    prelude::*,
};
assert_eq!(&vec_array(), &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

impl<A> AsRef<[<A as Array>::Item]> for VecArray<A> where
    A: Array
[src]

impl<A> AsMut<[<A as Array>::Item]> for VecArray<A> where
    A: Array
[src]

impl<A: Eq> Eq for VecArray<A>[src]

impl<A: Copy> Copy for VecArray<A>[src]

impl<A: Clone> Clone for VecArray<A>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<A: PartialEq> PartialEq<VecArray<A>> for VecArray<A>[src]

impl<A: PartialOrd> PartialOrd<VecArray<A>> for VecArray<A>[src]

impl<A: Default> Default for VecArray<A>[src]

impl<'a, A> IntoIterator for &'a VecArray<A> where
    A: Array
[src]

type Item = &'a A::Item

The type of the elements being iterated over.

type IntoIter = Iter<'a, A::Item>

Which kind of iterator are we turning this into?

impl<'a, A> IntoIterator for &'a mut VecArray<A> where
    A: Array
[src]

type Item = &'a mut A::Item

The type of the elements being iterated over.

type IntoIter = IterMut<'a, A::Item>

Which kind of iterator are we turning this into?

impl<A: Hash> Hash for VecArray<A>[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<A> Deref for VecArray<A> where
    A: Array
[src]

type Target = [A::Item]

The resulting type after dereferencing.

impl<A> DerefMut for VecArray<A> where
    A: Array
[src]

impl<A> Debug for VecArray<A> where
    A: Array,
    A::Item: Debug
[src]

impl<A> FromIterator<<A as Array>::Item> for VecArray<A> where
    A: Array
[src]

impl<A> Borrow<[<A as Array>::Item]> for VecArray<A> where
    A: Array
[src]

impl<A> BorrowMut<[<A as Array>::Item]> for VecArray<A> where
    A: Array
[src]

impl<A> Serialize for VecArray<A> where
    A: Array,
    A::Item: Serialize
[src]

impl<'de, A> Deserialize<'de> for VecArray<A> where
    A: Array,
    A::Item: Deserialize<'de>, 
[src]

Auto Trait Implementations

impl<A> Send for VecArray<A> where
    A: Send

impl<A> Sync for VecArray<A> where
    A: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From 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 for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto 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 for T where
    T: ?Sized
[src]

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

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

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]