blob: 538609b981adf5a965712c6ec12ef2d99f79783b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// run-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(generators, generator_trait)]
use std::ops::{GeneratorState, Generator};
use std::pin::Pin;
use std::panic;
fn main() {
let mut foo = || {
if true {
return
}
yield;
};
match Pin::new(&mut foo).resume(()) {
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
match panic::catch_unwind(move || Pin::new(&mut foo).resume(())) {
Ok(_) => panic!("generator successfully resumed"),
Err(_) => {}
}
}
|