about summary refs log tree commit diff
path: root/tests/ui/coroutine/gen_fn_iter.rs
blob: 9cd75551ad45c7d660430a7f4f186f4091a21cb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//@ edition: 2024
//@ 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);
}