[−][src]Struct subset::multi::Subset
Multi-subset of slice's items that is able to iterate forward and backward over references to selected items. Each item of a slice can be selected more than once.
The only difference between Subset and SubsetMut is that Subset holds immutable reference to original set.
Methods
impl<'a, T> Subset<'a, T>
[src]
pub fn new(set: &'a [T], idxs: &'a [usize]) -> Result<Self, SubsetError>
[src]
Constructs a multi-subset from the whole set and indexes of the selected items. Array bounds is checked. Note that subsets are not designed for ZSTs.
Examples
let set = [1, 2, 3]; let idxs = [0, 1]; let subset = Subset::new(&set, &idxs).unwrap();
Errors
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 multi-subset from the whole set and indexes of the selected items. No array bounds check.
pub fn set(&self) -> &[T]
[src]
Returns the original slice.
pub fn idxs(&self) -> &[usize]
[src]
Returns indexes of selected items.
pub fn is_unique(&self) -> bool
[src]
Checks that no items are selected twice or more.
if is_unique() == true
then subset can be converted to unique::Subset.
Examples
let set = ["one", "two", "three"]; let idxs = [0, 1]; let subset = Subset::new(&set, &idxs).unwrap(); if subset.is_unique() { let uniq_subset: subset::unique::Subset<_> = subset.try_into().unwrap(); }
pub unsafe fn to_unique_unchecked(self) -> Subset<'a, T>
[src]
Converts to subset::unique::Subset
.
Uniqueness of indexes is not checked.
ⓘ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?
ⓘImportant traits for Iter<'a, T>fn into_iter(self) -> Iter<'a, T>
[src]
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> From<SubsetMut<'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.
fn try_from(s: Subset<'a, T>) -> Result<Self, SubsetError>
[src]
Auto Trait Implementations
impl<'a, T> Send for Subset<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for Subset<'a, T>
impl<'a, T> Sync for Subset<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> UnwindSafe for Subset<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T> RefUnwindSafe for Subset<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
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, 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,