Crates.io | iter-skak |
lib.rs | iter-skak |
version | 0.2.0 |
source | src |
created_at | 2022-06-20 18:22:47.341618 |
updated_at | 2022-06-21 18:08:42.267252 |
description | Combines std::iter::Skip and std::iter::Take into one |
homepage | |
repository | https://github.com/NyxKrage/iter-skak |
max_upload_size | |
id | 609717 |
size | 8,538 |
This creates a new iterator type that combines the functionality of std::iter::Skip and std::iter::Take. Usage is as follows
let v: Vec<i32> = vec![1,2,3,4,5,6,7,8];
// Takes the first 2 values of `v` into `taken` and makes the rest of the iterator accessible through `next`
let (mut taken, mut next) = Skak::new(v.iter(), 2);
let mut count = 0;
assert_eq!(next.size_hint().0, v.len() - 2);
while next.size_hint().0 > 0 {
println!("Set {}", count);
// You can then call `Skak::skip` with your previous iterator, and a new amount of elements to be skipped
(taken, next) = Skak::skip(next, 2);
count += 1;
}