2018-03-21 18:32:44 -07:00
|
|
|
#![feature(generators, generator_trait)]
|
2016-12-26 14:34:03 +01:00
|
|
|
|
2018-10-04 20:49:38 +02:00
|
|
|
use std::marker::Unpin;
|
2017-08-09 13:56:19 -07:00
|
|
|
use std::ops::Generator;
|
|
|
|
|
2020-01-25 20:03:10 +01:00
|
|
|
pub fn foo() -> impl Generator<(), Yield = (), Return = ()> {
|
2017-08-09 13:56:19 -07:00
|
|
|
|| {
|
2017-08-09 16:38:05 -07:00
|
|
|
if false {
|
2017-08-09 13:56:19 -07:00
|
|
|
yield;
|
|
|
|
}
|
|
|
|
}
|
2017-07-11 12:57:05 -07:00
|
|
|
}
|
2017-08-09 16:38:05 -07:00
|
|
|
|
2020-01-25 20:03:10 +01:00
|
|
|
pub fn bar<T: 'static>(t: T) -> Box<Generator<(), Yield = T, Return = ()> + Unpin> {
|
2017-08-09 16:38:05 -07:00
|
|
|
Box::new(|| {
|
|
|
|
yield t;
|
|
|
|
})
|
|
|
|
}
|