[−][src]Struct subset::unique::Subset
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?
ⓘ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: 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]
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.
fn try_from(s: SubsetMut<'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,