Expand description
🤸♀️ More iterator adaptors.
This crate provides some useful iterator adaptors and functions. Unlike
itertools this crate provides a separate
extension trait for each adaptor. Additionally, each type of adaptor is
feature flagged so you only have to compile the features you need.
§Getting started
Add the crate to Cargo manifest.
cargo add itermore --features fullAnd bring the extension traits into scope.
use itermore::prelude::*;Now you can use extension methods like array_windows on any iterator.
for [a, b, c] in iter.array_windows() {
println!("{} {} {}", a, b, c)
}
// Outputs
// 1 2 3
// 2 3 4
// 3 4 5It is recommended to only enable the features that you need. For example if
you only want the array_combinations adaptor you would add the following
to your Cargo manifest.
[dependencies]
itermore = { version = "*", features = ["array_combinations"]}§Provided functionality
§Methods
collect_array: Collects an iterator into an array.min_maxand friends: Returns the minimum and maximum element of an iterator.next_chunk: Returns the nextNelements of the iterator as an array.sortedand friends: Returns a new iterator with all elements sorted.
§Adaptors
array_chunksreturns an iterator overNelements of the iterator at a time.array_windowsreturns an iterator over all contiguous windows of lengthN.array_combinationsreturns an iterator overKlength combinations of all the elements in the underlying iterator.array_combinations_with_repsreturns an iterator overKlength combinations with repetitions/replacements of all the elements in the underlying iterator.cartesian_productreturns an iterator over the cartesian product of the element sets of two iterators.circular_array_windowsreturns an iterator over all contiguous windows of lengthNthat wraps around at the end.combinationsreturns an iterator overklength combinations of all the elements in the underlying iterator.combinations_with_repsreturns an iterator overklength combinations with repetitions/replacements of all the elements in the underlying iterator.
Modules§
- prelude
- Re-exports all iterator extension traits.
Macros§
- cartesian_
product - Returns an iterator over the cartesian product of the element sets of multiple iterators (up to 12).
Structs§
- Array
Chunks array_chunks - An iterator over
Nelements of the iterator at a time. - Array
Combinations array_combinations - An iterator that iterates over
Klength combinations of all the elements in the underlying iterator. - Array
Combinations With Reps array_combinations_with_reps - An iterator that iterates over
Klength combinations with repetitions/replacements of all the elements in the underlying iterator. - Array
Windows array_windows - An iterator over all contiguous windows of length
N. - Cartesian
Product cartesian_product - An iterator over the cartesian product of the element sets of two iterators
IandJ. - Circular
Array Windows circular_array_windows - An iterator over all contiguous windows of length
Nwrapping back to the first elements when the window would otherwise exceed the length of the iterator. - Combinations
combinations - An iterator that iterates over
klength combinations of all the elements in the underlying iterator. - Combinations
With Reps combinations_with_reps - An iterator that iterates over
Klength combinations with repetitions/replacements of all the elements in the underlying iterator.
Traits§
- Iter
Array Chunks array_chunks - An extension trait that provides the
array_chunksmethod for iterators. - Iter
Array Combinations array_combinations - An extension trait that provides the
array_combinationsmethod for iterators. - Iter
Array Combinations With Reps array_combinations_with_reps - An extension trait that provides the
array_combinations_with_repsmethod for iterators. - Iter
Array Windows array_windows - An extension trait that provides the
array_windowsmethod for iterators. - Iter
Cartesian Product cartesian_product - An extension trait that provides the
cartesian_productmethod for iterators. - Iter
Circular Array Windows circular_array_windows - Iter
Collect Array collect_array - An extension trait that provides the
collect_arraymethod for iterators. - Iter
Combinations combinations - An extension trait that provides the
combinationsmethod for iterators. - Iter
Combinations With Reps combinations_with_reps - An extension trait that provides the
combinations_with_repsmethod for iterators. - Iter
MinMax min_max - An extension trait that provides the
min_maxmethod and friends for iterators. - Iter
Next Chunk next_chunk - An extension trait that provides the
next_chunkmethod for iterators. - Iter
Sorted sorted - An extension trait that provides the
sortedmethod and friends for iterators.