Crates.io | eternal_iterator |
lib.rs | eternal_iterator |
version | 0.1.4 |
source | src |
created_at | 2022-04-18 12:01:13.654411 |
updated_at | 2022-07-15 11:42:29.99629 |
description | Trait implementation to promise that the iterator iterates forever. |
homepage | |
repository | https://github.com/yasuo-ozu/eternal_iterator |
max_upload_size | |
id | 569831 |
size | 13,658 |
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));
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]);