Crates.io | combin-iterator |
lib.rs | combin-iterator |
version | 0.2.2 |
source | src |
created_at | 2024-01-24 17:42:19.187358 |
updated_at | 2024-02-06 22:15:51.050131 |
description | Some usefull facilities for combining iterators |
homepage | |
repository | https://github.com/S3lios/rust-combin-iterator |
max_upload_size | |
id | 1112660 |
size | 41,144 |
The combin-iterator crate provides a set of combinators for creating iterators through combinations of existing iterators. It aims to simplify the process of composing and chaining iterators to create more complex iteration patterns.
Combinator Macros: Use convenient macros to combine multiple iterators and create complex iteration sequences.
Round-Robin Alternation: Use the Altern iterator to alternate between elements produced by multiple iterators in a round-robin fashion.
Note: This crate is currently in development, and only little features are yet available.
use combin_iterator::altern;
use combin_iterator::altern::AlternWith;
fn main() {
let vec1 = vec![1, 4, 7, 9];
let vec2 = vec![2, 5];
let vec3 = vec![3, 6, 8];
// Use the altern! macro for alternating iteration
let altern_iter = altern!(vec1.iter(), vec2.iter(), vec3.iter());
// Iterate over the elements
for element in altern_iter {
println!("{}", element);
} // Print: 1 2 3 5 6 7 8 9
// Or use the AlternWith trait (i.e. combin_iterator::altern::BiAltern)
let trait_iter = vec1.iter().altern_with(vec2.iter());
// Iterate over the elements
for element in trait_iter {
println!("{}", element);
} // Print: 1 2 4 5 7 9
}
Add the following dependency to your Cargo.toml:
[dependencies]
combin-iterator = "0.2.2"
This project is licensed under the MIT License or Apache 2.0 - see the LICENSE file for details.
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
Happy Iterating with combin-iterator!