Function wasmtime_environ::__core::iter::from_generator
source · pub fn from_generator<G>(generator: G) -> FromGenerator<G>where
G: Generator<(), Return = ()> + Unpin,
🔬This is a nightly-only experimental API. (
iter_from_generator
)Expand description
Creates a new iterator where each iteration calls the provided generator.
Similar to iter::from_fn
.
Examples
#![feature(generators)]
#![feature(iter_from_generator)]
let it = std::iter::from_generator(|| {
yield 1;
yield 2;
yield 3;
});
let v: Vec<_> = it.collect();
assert_eq!(v, [1, 2, 3]);