#![feature(coroutines, coroutine_trait)] use std::marker::Unpin; use std::ops::Coroutine; pub fn foo() -> impl Coroutine<(), Yield = (), Return = ()> { || { if false { yield; } } } pub fn bar(t: T) -> Box + Unpin> { Box::new(|| { yield t; }) }