mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
20 lines
417 B
Rust
20 lines
417 B
Rust
//@ edition: 2024
|
|
//@ compile-flags: -Zunstable-options
|
|
//@ run-pass
|
|
#![feature(gen_blocks)]
|
|
|
|
// make sure that a ridiculously simple gen fn works as an iterator.
|
|
|
|
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);
|
|
}
|