lerox: and_maybe is actually and_either with g = identity function
This commit is contained in:
parent
24f7c95ae2
commit
a8f524d742
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user