eval
Log in

Fibonacci iterator

10 points

Implement Iterator for Fib so that fib() yields the infinite sequence 0, 1, 1, 2, 3, 5, 8, and so on, as u64. Do not collect into a vector; the iterator must produce values one at a time.

Required signature

pub struct Fib {     // add the state you need }  pub fn fib() -> Fib {     todo!() }  impl Iterator for Fib {     type Item = u64;      fn next(&mut self) -> Option<u64> {         todo!()     } }

Visible tests

Your solution

Log in to submit a solution.