2023-10-19 16:46:28 -05:00
|
|
|
#![feature(coroutines, coroutine_trait)]
|
2023-10-19 11:06:43 -05:00
|
|
|
use std::ops::{Coroutine, CoroutineState};
|
2018-10-04 13:49:38 -05:00
|
|
|
use std::pin::Pin;
|
2018-10-12 09:16:29 -05:00
|
|
|
|
|
|
|
fn dangle(x: &mut i32) -> &'static mut i32 {
|
|
|
|
let mut g = || {
|
|
|
|
yield;
|
|
|
|
x
|
|
|
|
};
|
|
|
|
loop {
|
2020-01-25 13:03:10 -06:00
|
|
|
match Pin::new(&mut g).resume(()) {
|
2023-10-19 11:06:43 -05:00
|
|
|
CoroutineState::Complete(c) => return c,
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2023-10-19 11:06:43 -05:00
|
|
|
CoroutineState::Yielded(_) => (),
|
2018-10-12 09:16:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|