mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
20 lines
445 B
Rust
20 lines
445 B
Rust
#![feature(generators, generator_trait)]
|
|
use std::ops::{Generator, GeneratorState};
|
|
use std::pin::Pin;
|
|
|
|
fn dangle(x: &mut i32) -> &'static mut i32 {
|
|
let mut g = || {
|
|
yield;
|
|
x
|
|
};
|
|
loop {
|
|
match Pin::new(&mut g).resume(()) {
|
|
GeneratorState::Complete(c) => return c,
|
|
//~^ ERROR lifetime may not live long enough
|
|
GeneratorState::Yielded(_) => (),
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {}
|