]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generator/yield-in-box.rs
Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
[rust.git] / src / test / ui / generator / yield-in-box.rs
1 // run-pass
2 // Test that box-statements with yields in them work.
3
4 #![feature(generators, box_syntax, generator_trait)]
5 use std::pin::Pin;
6 use std::ops::Generator;
7 use std::ops::GeneratorState;
8
9 fn main() {
10     let x = 0i32;
11     || { //~ WARN unused generator that must be used
12         let y = 2u32;
13         {
14             let _t = box (&x, yield 0, &y);
15         }
16         match box (&x, yield 0, &y) {
17             _t => {}
18         }
19     };
20
21     let mut g = |_| box yield;
22     assert_eq!(Pin::new(&mut g).resume(1), GeneratorState::Yielded(()));
23     assert_eq!(Pin::new(&mut g).resume(2), GeneratorState::Complete(box 2));
24 }