Crate iterextd

Source
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.
ArrayCloned
An iterator that clones the array elements of the base iterator.
ArrayCopied
An iterator that copies the array elements of the base iterator.
CircleBresenhamSeq
An iterator for creating a circle sequentially in a clockwise direction.
CombineIters
Combine two iterators in pieces, specifying the length of each separately.
Extrapolate
A struct for the extrapolate iterator adapter.
GenCirclePoints
Store data for generating circle points.
GenRangeBounds
An iterator that allows creating RangeInclusive slice boundaries.
InclusiveStepBy
Iterator to step iterators by a given amount including the first and last element.
LastTaken
An iterator adapter that preserves the element of the last iteration.
MapByThree
An iterator that yields three elements each iteration.
MapByTwo
An iterator that yields two elements each iteration.
MapIters
Iterator adapter which provides two iterators for its closure at each iteration.
MissingIntegers
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.
RangeIcvToTup
An iterator that converts a RangeInclusive at each iteration to a tuple.
RangeToTup
An iterator that converts a Range at each iteration to a tuple.
Scaling
Structure that stores data, parameters for the scaling iterator adapter.
SkipStepBy
Iterator adapter with skip and step capabilities in one.
SliceCopied
An iterator that copies the slice elements of the base iterator at each iteration.
SliceModify
An iterator that allows modification of a slice.
StepBoundary
An iterator to determine the boundaries of each step in a sequence.
StepByFn
Iterator adapter, with variable step.
TakeSkipCyclic
An iterator that takes n and skips m iterator elements cyclically.
TupToRange
An iterator that converts a tuple at each iteration to a Range.
TupToRangeIcv
An iterator that converts a tuple at each iteration to a RangeInclusive.
TupleImut
Immutable tuple iterator.
TupleMut
Mutable tuple iterator.

Traits§

IterExtd
Trait extends the functionality of the standard iterator.
Scaler
An iterator that scales the values of the input iterator to the specified range.
SliceModifyIter
Iterator with external slice indexing.
SwapIter
An iterator adapter that swaps elements in two sequences.
TupleIntoIter
Tuple iterator, adds the ability to get elements by value.
TupleIter
A trait that allows iterating over a tuple.
TupleIternitern
A trait that allows iteration over N elements of a tuple.