in gazebo/src/ext/iter.rs [256:277]
fn try_all<F, E>(mut self, f: F) -> Result<bool, E>
where
Self: Sized,
F: FnMut(Self::Item) -> Result<bool, E>,
{
// TODO migrate use of Result<(), Option<E>> to ControlFlow when it's no longer unstable
fn check<T, E>(
mut f: impl FnMut(T) -> Result<bool, E>,
) -> impl FnMut((), T) -> Result<(), Option<E>> {
move |(), x| match f(x) {
Ok(true) => Ok(()),
Ok(false) => Err(None),
Err(e) => Err(Some(e)),
}
}
match self.try_fold((), check(f)) {
Ok(()) => Ok(true),
Err(None) => Ok(false),
Err(Some(e)) => Err(e),
}
}