integer: Match based on base, if present

This commit is contained in:
2023-09-25 16:43:50 -05:00
parent 03660fd641
commit 247bb1f8f8
2 changed files with 35 additions and 6 deletions

View File

@@ -59,4 +59,15 @@ pub trait Combinator: Sized {
where Self: Clone {
self.clone().and(f).or(|_| g(self))
}
/// Returns the result of the first f that succeeds, or self
fn and_one_of(mut self, f: &[&dyn Fn(Self) -> Self]) -> Self {
for &f in f {
self = self.into_alright().and(f);
if self.is_alright() {
break;
}
}
self
}
}