iter-skak

Crates.ioiter-skak
lib.rsiter-skak
version0.2.0
sourcesrc
created_at2022-06-20 18:22:47.341618
updated_at2022-06-21 18:08:42.267252
descriptionCombines std::iter::Skip and std::iter::Take into one
homepage
repositoryhttps://github.com/NyxKrage/iter-skak
max_upload_size
id609717
size8,538
Carsten Kragelund Jørgensen (nyxkrage)

documentation

README

iter-sk(ip)(t)ak(e)

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;
}
Commit count: 2

cargo fmt