Infinite loop in Fizzy exercise tests

Hi,

I was recently working on the Fizzy exercise and it seems that the f64 and Fizzable test cases end up looping indefinitely on an iterator.

It looks like the problem is here:

let actual = fizz_buzz::<Fizzable>()
  .apply(std::iter::successors(Some(Fizzable(1)), |prev| {
              Some(*prev + 1.into())
   }))
  .take(16)
  .collect::<Vec<_>>();

This seems to end up passing the whole, infinite, iterator to the apply method, before the take(16) , when it should probably pass only the taken elements, like this:

let actual = fizz_buzz::<Fizzable>()
  .apply(std::iter::successors(Some(Fizzable(1)), |prev| {
              Some(*prev + 1.into())
   })
  .take(16)
  )
  .collect::<Vec<_>>();

This ends up in a timeout in the f64 case and in an u8 overflow on the first Fizzable test case.

While I was writing this issue I found an unanswered topic from 2024 raising the same issue (https://forum.exercism.org/t/rust-fizzy-test-for-f64/11780 ).

I’m assuming you consume the entire iterator eagerly in your implementation of apply. The solution is to not do that.

You’re right, I didn’t thought this out enough.