https://github.com/rossmacarthur/itermore
🤸 More iterator adaptors
https://github.com/rossmacarthur/itermore
chunks crate iterator rust
Last synced: about 1 month ago
JSON representation
🤸 More iterator adaptors
- Host: GitHub
- URL: https://github.com/rossmacarthur/itermore
- Owner: rossmacarthur
- License: apache-2.0
- Created: 2021-10-06T20:44:05.000Z (over 3 years ago)
- Default Branch: trunk
- Last Pushed: 2025-03-21T16:54:00.000Z (2 months ago)
- Last Synced: 2025-04-13T16:09:09.561Z (about 1 month ago)
- Topics: chunks, crate, iterator, rust
- Language: Rust
- Homepage:
- Size: 170 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# itermore
[](https://crates.io/crates/itermore)
[](https://docs.rs/itermore)
[](https://github.com/rossmacarthur/itermore/actions/workflows/build.yaml)🤸♀️ More iterator adaptors.
This crate provides some useful iterator adaptors and functions. Unlike
[`itertools`](https://docs.rs/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.
```sh
cargo add itermore --features full
```And bring the extension traits into scope.
```rust
use itermore::prelude::*;
```Now you can use extension methods like [`array_windows`][array_windows] on any iterator.
```rust
for [a, b, c] in iter.array_windows() {
println!("{} {} {}", a, b, c)
}
// Outputs
// 1 2 3
// 2 3 4
// 3 4 5
```It is recommended to only enable the features that you need. For example if
you only want the [`array_combinations`][array_combinations] adaptor you would add the following
to your Cargo manifest.```toml
[dependencies]
itermore = { version = "*", features = ["array_combinations"]}
```## Provided functionality
### Methods
- [`collect_array`][collect_array]: Collects an iterator into an array.
- [`min_max`][min_max] and friends: Returns the minimum and maximum element of an
iterator.
- [`next_chunk`][next_chunk]: Returns the next `N` elements of the iterator as an array.
- [`sorted`][sorted] and friends: Returns a new iterator with all elements sorted.### Adaptors
- [`array_chunks`][array_chunks] returns an iterator over `N` elements of the iterator at
a time.
- [`array_windows`][array_windows] returns an iterator over all contiguous windows of
length `N`.
- [`array_combinations`][array_combinations] returns an iterator over `K` length combinations of
all the elements in the underlying iterator.
- [`array_combinations_with_reps`][array_combinations_with_reps] returns an iterator over `K` length
combinations with repetitions/replacements of all the elements in the
underlying iterator.
- [`cartesian_product`][cartesian_product] returns an iterator over the cartesian product of
the element sets of two iterators.
- [`circular_array_windows`][circular_array_windows] returns an iterator over all contiguous windows
of length `N` that wraps around at the end.
- [`combinations`][combinations] returns an iterator over `k` length combinations of all
the elements in the underlying iterator.
- [`combinations_with_reps`][combinations_with_reps] returns an iterator over `k` length
combinations with repetitions/replacements of all the elements in the
underlying iterator.## License
This project is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.
[array_chunks]: https://docs.rs/itermore/latest/itermore/trait.IterArrayChunks.html#method.array_chunks
[array_combinations]: https://docs.rs/itermore/latest/itermore/trait.IterArrayCombinations.html#method.array_combinations
[array_combinations_with_reps]: https://docs.rs/itermore/latest/itermore/trait.IterArrayCombinationsWithReps.html#method.array_combinations_with_reps
[array_windows]: https://docs.rs/itermore/latest/itermore/trait.IterArrayWindows.html#method.array_windows
[cartesian_product]: https://docs.rs/itermore/latest/itermore/trait.IterCartesianProduct.html#method.cartesian_product
[circular_array_windows]: https://docs.rs/itermore/latest/itermore/trait.IterCircularArrayWindows.html#method.circular_array_windows
[collect_array]: https://docs.rs/itermore/latest/itermore/trait.IterCollectArray.html#method.collect_array
[combinations]: https://docs.rs/itermore/latest/itermore/trait.IterCombinations.html#method.combinations
[combinations_with_reps]: https://docs.rs/itermore/latest/itermore/trait.IterCombinationsWithReps.html#method.combinations_with_reps
[min_max]: https://docs.rs/itermore/latest/itermore/trait.IterMinMax.html#method.min_max
[next_chunk]: https://docs.rs/itermore/latest/itermore/trait.IterNextChunk.html#method.next_chunk
[sorted]: https://docs.rs/itermore/latest/itermore/trait.IterSorted.html#method.sorted