mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Add a failing xcrate generator test
This commit is contained in:
parent
e181060a59
commit
be95ca4b17
@ -12,14 +12,16 @@
|
|||||||
|
|
||||||
use std::ops::Generator;
|
use std::ops::Generator;
|
||||||
|
|
||||||
fn bar() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn foo() -> impl Generator<Yield = (), Return = ()> {
|
pub fn foo() -> impl Generator<Yield = (), Return = ()> {
|
||||||
|| {
|
|| {
|
||||||
if bar() {
|
if false {
|
||||||
yield;
|
yield;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bar<T: 'static>(t: T) -> Box<Generator<Yield = T, Return = ()>> {
|
||||||
|
Box::new(|| {
|
||||||
|
yield t;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -23,4 +23,15 @@ fn main() {
|
|||||||
GeneratorState::Complete(()) => {}
|
GeneratorState::Complete(()) => {}
|
||||||
s => panic!("bad state: {:?}", s),
|
s => panic!("bad state: {:?}", s),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut foo = xcrate::bar(3);
|
||||||
|
|
||||||
|
match foo.resume() {
|
||||||
|
GeneratorState::Yielded(4) => {}
|
||||||
|
s => panic!("bad state: {:?}", s),
|
||||||
|
}
|
||||||
|
match foo.resume() {
|
||||||
|
GeneratorState::Complete(()) => {}
|
||||||
|
s => panic!("bad state: {:?}", s),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user