Skip to content

Commit

Permalink
Implement FlattenOk::rfold
Browse files Browse the repository at this point in the history
  • Loading branch information
kinto-b committed May 1, 2024
1 parent 10fb9d1 commit e9707bc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/flatten_ok.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ where
}
}
}

fn rfold<B, F>(self, init: B, mut f: F) -> B
where
Self: Sized,
F: FnMut(B, Self::Item) -> B,
{
self.iter.rfold(init, |acc, x| match x {
Ok(it) => it.into_iter().rfold(acc, |a, o| f(a, Ok(o))),
Err(e) => f(acc, Err(e)),
})
}
}

impl<I, T, E> Clone for FlattenOk<I, T, E>
Expand Down

0 comments on commit e9707bc

Please sign in to comment.