Crate eternal_iterator

Crate eternal_iterator 

Source
Expand description

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

This crate is compatible with core::iter. So you can use methods in core::iter to generate iterators.

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));

Modules§

prelude

Structs§

FromFn
It is used on the implementation of from_fn(). See from_fn() document for details.
Successors
It is used on the implementation of successors(). See successors() document for details.
UnsafeWrapper
It is used on the implementation of wrap_unsafe(). See wrap_unsafe() document for details.

Traits§

EternalIterator
Like Iterator, but promises that the iterator iterates forever.

Functions§

from_fn
Creates a new iterator where each iteration calls the provided closure F: FnMut() -> T.
successors
Creates a new iterator where each successive item is computed based on the preceding one.
wrap
Safe version of wrap_unsafe()
wrap_unsafe
Wraps Iterator to be seen as EternalIterator.