Expand description
Adapters that extend Iterator
functionality.
§Variable step:
use iterextd::IterExtd;
let logic_fn = |s: &mut usize| {
if *s == 0 {
*s = 1;
1
} else {
*s += 1;
*s
}
};
let iter = (0..18).step_by_fn(logic_fn);
let vec = iter.collect::<Vec<_>>();
assert_eq!(vec, vec![0, 2, 5, 9, 14]);
§Collect a zeroed array:
use iterextd::IterExtd;
let arr = [1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let iter = arr.iter().filter(|elem| *elem % 2 == 0).copied();
let arr: (usize, [u8; 10]) = iter.collect_arr_zeroed();
assert_eq!(arr, (5, [2, 4, 6, 8, 10, 0, 0, 0, 0, 0]));
§Collect windows from arrays:
use iterextd::IterExtd;
let arr = [0, 1, 2, 3, 4, 5, 6, 7];
let iter = arr.into_iter();
let iter = iter.clone().map_iters(iter.previous(1).skip(2), |self_iter, arg_iter| {
let (pre_elem, elem) = arg_iter.next()?;
Some([self_iter.next()?, pre_elem, elem])
});
let vec = iter.collect::<Vec<_>>();
assert_eq!(vec, vec![[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]);
Structs§
- Returns an iterator of arrays with N elements.
- An iterator that clones the array elements of the base iterator.
- An iterator that copies the array elements of the base iterator.
- An iterator for creating a circle sequentially in a clockwise direction.
- Combine two iterators in pieces, specifying the length of each separately.
- A struct for the extrapolate iterator adapter.
- Store data for generating circle points.
- An iterator that allows creating RangeInclusive slice boundaries.
- Iterator to step iterators by a given amount including the first and last element.
- An iterator adapter that preserves the element of the last iteration.
- An iterator that yields three elements each iteration.
- An iterator that yields two elements each iteration.
- Iterator adapter which provides two iterators for its closure at each iteration.
- An iterator adapter that returns missing numbers.
- The iterator adapter that offsets the points.
- An iterator adapter that retains the current element on each iteration.
- An iterator that converts a
RangeInclusive
at each iteration to a tuple. - An iterator that converts a
Range
at each iteration to a tuple. - Iterator adapter with skip and step capabilities in one.
- An iterator that copies the slice elements of the base iterator at each iteration.
- An iterator that allows modification of a slice.
- An iterator to determine the boundaries of each step in a sequence.
- Iterator adapter, with variable step.
- An iterator that converts a tuple at each iteration to a
Range
. - An iterator that converts a tuple at each iteration to a
RangeInclusive
. - Immutable tuple iterator.
- Mutable tuple iterator.
Traits§
- Trait extends the functionality of the standard iterator.
- Iterator with external slice indexing.
- An iterator adapter that swaps elements in two sequences.
- Tuple iterator, adds the ability to get elements by value.
- A trait that allows iterating over a tuple.
- Tuple
Itern itern
A trait that allows iteration over N elements of a tuple.