eternal_iterator

Crates.ioeternal_iterator
lib.rseternal_iterator
version0.1.4
sourcesrc
created_at2022-04-18 12:01:13.654411
updated_at2022-07-15 11:42:29.99629
descriptionTrait implementation to promise that the iterator iterates forever.
homepage
repositoryhttps://github.com/yasuo-ozu/eternal_iterator
max_upload_size
id569831
size13,658
yozu (yasuo-ozu)

documentation

README

eternal_iterator

Test Status Crate Docs Minimum rustc version

This Rust crate provides EternalIterator trait, which promises that the iterator iterates forever.

let mut it = core::iter::repeat(123_i32).map(|i| i * 2)
		.enumerate().skip(5).step_by(2).zip(core::iter::once(3).chain(10..));
assert_eq!(it.next_eternal(), ((5, 246), 3));
assert_eq!(it.next_eternal(), ((7, 246), 10));
assert_eq!(it.next(), Some(((9, 246), 11)));
assert_eq!(it.next_eternal(), ((11, 246), 12));

generating fixed-size array

You can initialize arbitrary fixed-size array with eternal_iterator.

use eternal_iterator::prelude::*;
let arr: [i32; 5] = (0..).next_array();
assert_eq!(arr, [0, 1, 2, 3, 4]);
Commit count: 14

cargo fmt