2023-11-30 13:20:53 -06:00
|
|
|
//@ edition: 2024
|
|
|
|
//@ compile-flags: -Zunstable-options
|
|
|
|
//@ run-pass
|
|
|
|
#![feature(gen_blocks)]
|
|
|
|
|
2023-11-30 16:54:39 -06:00
|
|
|
// make sure that a ridiculously simple gen fn works as an iterator.
|
|
|
|
|
2023-11-30 13:20:53 -06:00
|
|
|
gen fn foo() -> i32 {
|
|
|
|
yield 1;
|
|
|
|
yield 2;
|
|
|
|
yield 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut iter = foo();
|
|
|
|
assert_eq!(iter.next(), Some(1));
|
|
|
|
assert_eq!(iter.next(), Some(2));
|
|
|
|
assert_eq!(iter.next(), Some(3));
|
|
|
|
assert_eq!(iter.next(), None);
|
|
|
|
}
|