2024-04-11 13:15:34 +00:00
|
|
|
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
|
2016-12-26 13:34:03 +00:00
|
|
|
|
2018-10-04 18:49:38 +00:00
|
|
|
use std::marker::Unpin;
|
2023-10-19 16:06:43 +00:00
|
|
|
use std::ops::Coroutine;
|
2017-08-09 20:56:19 +00:00
|
|
|
|
2023-10-19 16:06:43 +00:00
|
|
|
pub fn foo() -> impl Coroutine<(), Yield = (), Return = ()> {
|
2024-04-11 13:15:34 +00:00
|
|
|
#[coroutine]
|
2017-08-09 20:56:19 +00:00
|
|
|
|| {
|
2017-08-09 23:38:05 +00:00
|
|
|
if false {
|
2017-08-09 20:56:19 +00:00
|
|
|
yield;
|
|
|
|
}
|
|
|
|
}
|
2017-07-11 19:57:05 +00:00
|
|
|
}
|
2017-08-09 23:38:05 +00:00
|
|
|
|
2023-10-19 16:06:43 +00:00
|
|
|
pub fn bar<T: 'static>(t: T) -> Box<Coroutine<(), Yield = T, Return = ()> + Unpin> {
|
2024-04-11 13:15:34 +00:00
|
|
|
Box::new(
|
|
|
|
#[coroutine]
|
|
|
|
|| {
|
|
|
|
yield t;
|
|
|
|
},
|
|
|
|
)
|
2017-08-09 23:38:05 +00:00
|
|
|
}
|