? for ControlFlow

This commit is contained in:
AF 2023-07-24 17:19:49 +00:00
parent ed57b30d5d
commit c01963809e
3 changed files with 6 additions and 11 deletions

View File

@ -46,11 +46,8 @@ impl<'a, T: ?Sized + Functor<'a>, A: 'a, B: 'a, F: 'a + FnMut(A) -> T::F<Control
fn next(mut self) -> IterativeWrapped<'a, Self> { fn next(mut self) -> IterativeWrapped<'a, Self> {
let fstate = self.1(self.0); let fstate = self.1(self.0);
T::fmap(fstate, move |state| match state { T::fmap(fstate, move |state| {
ControlFlow::Continue(next_a) => { ControlFlow::Continue(BindableMut::new(state?, self.1))
ControlFlow::Continue(BindableMut::new(next_a, self.1))
}
ControlFlow::Break(b) => ControlFlow::Break(b),
}) })
} }
} }

View File

@ -120,9 +120,8 @@ impl<
fn next(self) -> IterativeWrapped<'a, Self> { fn next(self) -> IterativeWrapped<'a, Self> {
let fstate = self.0.next(); let fstate = self.0.next();
U::fmap(fstate, |ustate| match V::unstuff(ustate) { U::fmap(fstate, |ustate| {
ControlFlow::Continue(next_f) => ControlFlow::Continue(Self(next_f)), ControlFlow::Continue(Self(V::unstuff(ustate)?))
ControlFlow::Break(b) => ControlFlow::Break(b),
}) })
} }
} }

View File

@ -109,9 +109,8 @@ impl<'a, T: Monad<'a>, O: 'a + DeriveMonad, F: Iterative<'a, T = OverloadInstanc
type T = T; type T = T;
fn next(self) -> IterativeWrapped<'a, Self> { fn next(self) -> IterativeWrapped<'a, Self> {
T::fmap(self.0.next(), |state| match state { T::fmap(self.0.next(), |state| {
ControlFlow::Continue(next_f) => ControlFlow::Continue(Self::new(next_f)), ControlFlow::Continue(Self::new(state?))
ControlFlow::Break(b) => ControlFlow::Break(b),
}) })
} }
} }