[][src]Struct iterators_collection::filter::Exclude

pub struct Exclude<T> where
    T: Iterator,
    T::Item: PartialEq
{ /* fields omitted */ }

Excludes an object from iteration. Based on a blacklist

Example

use iterators_collection::filter::Exclude;
 
let array = [1, 2, 3, 4, 5];
let iter = array.iter().cloned();
// The iterator will ignore the values 3 and 5
let mut iter = Exclude::with_blacklist(iter, vec![3, 5]);
 
// Once 3 and 5 removed, there are only 1, 2 and 4
assert_eq!(iter.collect::<Vec<i32>>(), vec![1, 2, 4]);

Methods

impl<T> Exclude<T> where
    T: Iterator,
    T::Item: PartialEq
[src]

pub fn new(iterator: T) -> Self[src]

Returns a new object with an empty blacklist

pub fn with_blacklist(iterator: T, blacklist: Vec<T::Item>) -> Self[src]

Returns a new object with the given blacklist

pub fn exclude(&mut self, new: T::Item)[src]

Adds the object passed as arguments to the blacklist. It will be added only if it is not already inside the blacklist

pub fn force_exclude(&mut self, new: T::Item)[src]

Forces the object passed as arguments to be pushed to the blacklist. It will be added even if already present. You may want to avoid this behaviour and use exclude instead. Use it only if you are sure this element is not in the blacklist or if T::Item is designed as a == b, b == c but a != c. However, it is safe to use it. It may just lead to performance issues

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

Returns the iterator in use

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

Returns the iterator in use as a mutable reference

Trait Implementations

impl<T> ResettableIterator for Exclude<T> where
    T: ResettableIterator,
    T::Item: PartialEq
[src]

impl<T> ChildIterator for Exclude<T> where
    T: Iterator,
    T::Item: PartialEq
[src]

type Parent = T

impl<T> Iterator for Exclude<T> where
    T: Iterator,
    T::Item: PartialEq
[src]

type Item = T::Item

The type of the elements being iterated over.

impl<T: Clone> Clone for Exclude<T> where
    T: Iterator,
    T::Item: PartialEq,
    T::Item: Clone
[src]

Auto Trait Implementations

impl<T> Send for Exclude<T> where
    T: Send,
    <T as Iterator>::Item: Send

impl<T> Sync for Exclude<T> where
    T: Sync,
    <T as Iterator>::Item: Sync

impl<T> Unpin for Exclude<T> where
    T: Unpin,
    <T as Iterator>::Item: Unpin

impl<T> UnwindSafe for Exclude<T> where
    T: UnwindSafe,
    <T as Iterator>::Item: UnwindSafe

impl<T> RefUnwindSafe for Exclude<T> where
    T: RefUnwindSafe,
    <T as Iterator>::Item: RefUnwindSafe

Blanket Implementations

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

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

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> 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 = !

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]