pub fn iter_from_coroutine<G>(coroutine: G) -> FromCoroutine<G>
🔬This is a nightly-only experimental API. (
iter_from_coroutine
)Available on crate feature
nightly_coro
only.Expand description
core
Creates an iterator where each iteration calls the provided coroutine.
Re-exported from core
::iter::
from_coroutine
→iter_from_coroutine
.
Creates a new iterator where each iteration calls the provided coroutine.
Similar to iter::from_fn
.
§Examples
#![feature(coroutines)]
#![feature(iter_from_coroutine)]
let it = std::iter::from_coroutine(#[coroutine] || {
yield 1;
yield 2;
yield 3;
});
let v: Vec<_> = it.collect();
assert_eq!(v, [1, 2, 3]);