From 8bc32896c954dc61302498037d299a7fab14f8d4 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 23 Sep 2023 01:04:10 -0500 Subject: [PATCH] lerox: Fix and_any setting the Combinable to alright even when it should not be alright --- lerox/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lerox/src/lib.rs b/lerox/src/lib.rs index 938910b..94baed9 100644 --- a/lerox/src/lib.rs +++ b/lerox/src/lib.rs @@ -37,11 +37,13 @@ pub trait Combinator: Combinable + Sized { } /// Repeats the function f on self until it fails - fn and_any(mut self, f: impl Fn(Self) -> Self) -> Self { - while self.is_alright() { - self = self.and(&f) - } - self.alright() + fn and_any(self, f: impl Fn(Self) -> Self) -> Self { + self.and(|mut this| { + while this.is_alright() { + this = this.and(&f) + } + this.alright() + }) } /// Repeats the function f on self at least once, then until it fails.