mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
8d91e71e9a
These changes were made by manually running `rustfmt` on all of the test files, and then manually undoing all cases where the original formatting appeared to have been deliberate. `rustfmt +nightly --config-path=/dev/null --edition=2021 tests/run-coverage*/**/*.rs`
38 lines
933 B
Rust
38 lines
933 B
Rust
#![feature(generators, generator_trait)]
|
|
#![allow(unused_assignments)]
|
|
|
|
use std::ops::{Generator, GeneratorState};
|
|
use std::pin::Pin;
|
|
|
|
fn main() {
|
|
let mut generator = || {
|
|
yield 1;
|
|
return "foo";
|
|
};
|
|
|
|
match Pin::new(&mut generator).resume(()) {
|
|
GeneratorState::Yielded(1) => {}
|
|
_ => panic!("unexpected value from resume"),
|
|
}
|
|
match Pin::new(&mut generator).resume(()) {
|
|
GeneratorState::Complete("foo") => {}
|
|
_ => panic!("unexpected value from resume"),
|
|
}
|
|
|
|
let mut generator = || {
|
|
yield 1;
|
|
yield 2;
|
|
yield 3;
|
|
return "foo";
|
|
};
|
|
|
|
match Pin::new(&mut generator).resume(()) {
|
|
GeneratorState::Yielded(1) => {}
|
|
_ => panic!("unexpected value from resume"),
|
|
}
|
|
match Pin::new(&mut generator).resume(()) {
|
|
GeneratorState::Yielded(2) => {}
|
|
_ => panic!("unexpected value from resume"),
|
|
}
|
|
}
|