fib/
fib.rs

1use generator::{done, Gn};
2
3fn main() {
4    let g = Gn::new_scoped(|mut s| {
5        let (mut a, mut b) = (0, 1);
6        while b < 200 {
7            std::mem::swap(&mut a, &mut b);
8            b += a;
9            s.yield_(b);
10        }
11        done!();
12    });
13
14    for i in g {
15        println!("{i}");
16    }
17}