Skip to content

Infinite loop in Fizzy exercise tests #2124

@ciccio-87

Description

@ciccio-87

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.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions