cantrip 0.5.0

Practical extension methods for standard Rust collections
Documentation
pub(crate) fn unfold<A, F>(function: F) -> Unfold<F>
where
  F: FnMut() -> Option<A>,
{
  Unfold { function }
}

pub(crate) struct Unfold<F> {
  function: F,
}

impl<A, F> Iterator for Unfold<F>
where
  F: FnMut() -> Option<A>,
{
  type Item = A;

  #[inline]
  fn next(&mut self) -> Option<Self::Item> {
    (self.function)()
  }
}