lerox: and_maybe is actually and_either with g = identity function

This commit is contained in:
John 2023-09-23 00:57:33 -05:00
parent 24f7c95ae2
commit a8f524d742

View File

@ -27,7 +27,7 @@ pub trait Combinator: Combinable + Sized {
/// Returns the result of running f on self, or if it fails, the original self /// Returns the result of running f on self, or if it fails, the original self
fn and_maybe(self, f: impl Fn(Self) -> Self) -> Self fn and_maybe(self, f: impl Fn(Self) -> Self) -> Self
where Self: Clone { where Self: Clone {
self.clone().and(f).or(|_| self) self.and_either(f, |g| g)
} }
/// Returns the result of running f on self, or if it fails, runs g on self /// Returns the result of running f on self, or if it fails, runs g on self