[−][src]Trait skellige::prelude::IteratorExt
Iterator adaptors to simplify some operations
Required methods
pub fn consume(self) -> Self
[src]
Consume the entire iterator eagerly up until but not including the last call to get None. Allows caller to then call next and get None.
Examples
use fungus::core::*; assert_eq!(vec![0, 1, 2].into_iter().consume().next(), None);
pub fn drop(self, n: isize) -> Self where
Self: DoubleEndedIterator,
[src]
Self: DoubleEndedIterator,
Drop the first n
items if positive from the iterator eagerly and then return the
iterator. Drop the last |n|
items if negative from the iterator eagerly and then
return the iterator.
Examples
use fungus::core::*; assert_iter_eq(vec![1, 2, 3].into_iter().drop(1), vec![2, 3]); assert_iter_eq(vec![1, 2, 3].into_iter().drop(-1), vec![1, 2]);
pub fn first(self) -> Option<Self::Item>
[src]
Returns the first element of the iterator. Alias to nth(0).
first()
will return None
if n
is greater than or equal to the length of the
iterator.
Examples
use fungus::core::*; assert_eq!((0..10).filter(|&x| x == 2).first().unwrap(), 2);
pub fn first_result(self) -> Result<Self::Item, FuError>
[src]
If the iterator yields at least one element, the first element will be returned, otherwise an error will be returned.
Examples
use fungus::core::*; assert_eq!((0..10).filter(|&x| x == 2).first().unwrap(), 2);
pub fn last_result(self) -> Result<Self::Item, FuError>
[src]
If the iterator yields at least one element, the last element will be returned, otherwise an error will be returned.
Examples
use fungus::core::*; assert_eq!((0..10).filter(|&x| x == 2).last().unwrap(), 2);
pub fn single(self) -> Result<Self::Item, FuError>
[src]
If the iterator yields a single element, that element will be returned, otherwise an error will be returned.
Examples
use fungus::core::*; assert_eq!((0..10).filter(|&x| x == 2).single().unwrap(), 2);
pub fn slice(self, left: isize, right: isize) -> Self where
Self: Clone + DoubleEndedIterator,
[src]
Self: Clone + DoubleEndedIterator,
Slice returns this iterator eagerly to only iterate over the range of elements called out by the given indices. Allows for negative notation.
Note this operation uses count() to determine length which means cost O(n) out of the gate.
Examples
use fungus::core::*; let mut iter = vec![0, 1, 2].into_iter().slice(0, 0); assert_eq!(iter.next(), Some(0)); assert_eq!(iter.next(), None); let mut iter = vec![0, 1, 2].into_iter().slice(-1, -1); assert_eq!(iter.next(), Some(2)); assert_eq!(iter.next(), None); let mut iter = vec![0, 1, 2].into_iter().slice(-2, -1); assert_eq!(iter.next(), Some(1)); assert_eq!(iter.next(), Some(2)); assert_eq!(iter.next(), None);
pub fn some(self) -> bool
[src]
If the iterator yields at least one element, true will be returned else false
Examples
use fungus::core::*; assert_eq!((0..10).filter(|&x| x == 2).some(), true);
Implementors
impl<T> IteratorExt for T where
T: Iterator + ?Sized,
[src]
T: Iterator + ?Sized,
pub fn consume(self) -> T
[src]
pub fn drop(self, n: isize) -> T where
T: DoubleEndedIterator,
[src]
T: DoubleEndedIterator,
pub fn first(self) -> Option<<T as Iterator>::Item>
[src]
pub fn first_result(self) -> Result<<T as Iterator>::Item, FuError>
[src]
pub fn last_result(self) -> Result<<T as Iterator>::Item, FuError>
[src]
pub fn single(self) -> Result<<T as Iterator>::Item, FuError>
[src]
pub fn slice(self, left: isize, right: isize) -> T where
T: Clone + DoubleEndedIterator,
[src]
T: Clone + DoubleEndedIterator,