[][src]Struct subset::unique::Subset

pub struct Subset<'a, T> { /* fields omitted */ }

Subset of slice's items that is able to iterate forward and backward over immutable references to selected items. Each item of a slice can be selected no more than once.

Methods

impl<'a, T> Subset<'a, T>[src]

pub fn new(set: &'a [T], idxs: &'a [usize]) -> Result<Self, SubsetError>[src]

Constructs a subset from the whole set and indexes of the selected items. Both the uniqueness of the selected items and the array bounds is checked. Note that subsets are not designed for ZSTs.

Examples

let set = [1.0, 1.1, 1.2];
let idxs = [0, 1];
let subset = Subset::new(&set, &idxs).unwrap();

Errors

NotUnique, if there are duplicate indexes. OutOfBounds, if any index is >= set.len().

Panics

Panics if std::mem::size_of::<T>() == 0

pub unsafe fn new_unchecked(set: &'a [T], idxs: &'a [usize]) -> Self[src]

Constructs a subset from the whole set and indexes of the selected items. Neither the uniqueness of the selected items, nor the array bounds is checked.

pub fn set(&self) -> &[T][src]

Returns the original slice.

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

Returns indexes of selected items.

Important traits for Iter<'a, T>
pub fn iter(&self) -> Iter<T>[src]

Returns an iterator over immutable references to selected items.

Trait Implementations

impl<'a, T> IntoIterator for &'a Subset<'a, T>[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?

impl<'a, T> From<SubsetMut<'a, T>> for Subset<'a, T>[src]

impl<'a, T> From<Subset<'a, T>> for Subset<'a, T>[src]

impl<'a, T: Debug> Debug for Subset<'a, T>[src]

impl<'a, T> TryFrom<Subset<'a, T>> for Subset<'a, T>[src]

type Error = SubsetError

The type returned in the event of a conversion error.

impl<'a, T> TryFrom<SubsetMut<'a, T>> for Subset<'a, T>[src]

type Error = SubsetError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'a, T> Send for Subset<'a, T> where
    T: Sync

impl<'a, T> Unpin for Subset<'a, T>

impl<'a, T> Sync for Subset<'a, T> where
    T: Sync

impl<'a, T> UnwindSafe for Subset<'a, T> where
    T: RefUnwindSafe

impl<'a, T> RefUnwindSafe for Subset<'a, T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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