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§
- Adapter
- Universal adapter for iterators.
- ArrChunks
- Returns an iterator of arrays with N elements.
- Array
Cloned - An iterator that clones the array elements of the base iterator.
- Array
Copied - An iterator that copies the array elements of the base iterator.
- Circle
Bresenham Seq - An iterator for creating a circle sequentially in a clockwise direction.
- Combine
Iters - Combine two iterators in pieces, specifying the length of each separately.
- Extrapolate
- A struct for the extrapolate iterator adapter.
- GenCircle
Points - Store data for generating circle points.
- GenRange
Bounds - An iterator that allows creating RangeInclusive slice boundaries.
- Inclusive
Step By - Iterator to step iterators by a given amount including the first and last element.
- Last
Taken - An iterator adapter that preserves the element of the last iteration.
- MapBy
Three - An iterator that yields three elements each iteration.
- MapBy
Two - An iterator that yields two elements each iteration.
- MapIters
- Iterator adapter which provides two iterators for its closure at each iteration.
- Missing
Integers - An iterator adapter that returns missing numbers.
- Offset
- The iterator adapter that offsets the points.
- Previous
- An iterator adapter that retains the current element on each iteration.
- Range
IcvTo Tup - An iterator that converts a
RangeInclusive
at each iteration to a tuple. - Range
ToTup - An iterator that converts a
Range
at each iteration to a tuple. - Scaling
- Structure that stores data, parameters for the
scaling
iterator adapter. - Skip
Step By - Iterator adapter with skip and step capabilities in one.
- Slice
Copied - An iterator that copies the slice elements of the base iterator at each iteration.
- Slice
Modify - An iterator that allows modification of a slice.
- Step
Boundary - An iterator to determine the boundaries of each step in a sequence.
- Step
ByFn - Iterator adapter, with variable step.
- Take
Skip Cyclic - An iterator that takes
n
and skipsm
iterator elements cyclically. - TupTo
Range - An iterator that converts a tuple at each iteration to a
Range
. - TupTo
Range Icv - An iterator that converts a tuple at each iteration to a
RangeInclusive
. - Tuple
Imut - Immutable tuple iterator.
- Tuple
Mut - Mutable tuple iterator.
Traits§
- Iter
Extd - Trait extends the functionality of the standard iterator.
- Scaler
- An iterator that scales the values of the input iterator to the specified range.
- Slice
Modify Iter - Iterator with external slice indexing.
- Swap
Iter - An iterator adapter that swaps elements in two sequences.
- Tuple
Into Iter - Tuple iterator, adds the ability to get elements by value.
- Tuple
Iter - A trait that allows iterating over a tuple.
- Tuple
Itern itern
- A trait that allows iteration over N elements of a tuple.