diff --git a/src/data/arithm.rs b/src/data/arithm.rs index 573c611..13c3996 100644 --- a/src/data/arithm.rs +++ b/src/data/arithm.rs @@ -122,13 +122,13 @@ impl Number { .checked_add(rhs.to_i1024_bytes()) .map(Number::from) .and_then(|n| n.reshaped(Layout::signed(n.layout().bytes()), true)) - .and_then(|mut n| (n.reshape(Layout::signed(bytes)) || flags.wrap).then_some(n)), + .and_then(|mut n| (n.reshape(Layout::signed(bytes)) || flags.wrap).then(|| n)), (Layout::Integer(IntLayout { bytes, .. }), false) => self .to_u1024_bytes() .checked_add(rhs.to_u1024_bytes()) .map(Number::from) .and_then(|n| n.reshaped(Layout::unsigned(n.layout().bytes()), true)) - .and_then(|mut n| (n.reshape(Layout::unsigned(bytes)) || flags.wrap).then_some(n)), + .and_then(|mut n| (n.reshape(Layout::unsigned(bytes)) || flags.wrap).then(|| n)), (Layout::Float(_), _) => panic!("integer addition of float numbers"), } } @@ -150,13 +150,13 @@ impl Number { .checked_sub(rhs.to_i1024_bytes()) .map(Number::from) .and_then(|n| n.reshaped(Layout::signed(n.layout().bytes()), true)) - .and_then(|mut n| (n.reshape(Layout::signed(bytes)) || flags.wrap).then_some(n)), + .and_then(|mut n| (n.reshape(Layout::signed(bytes)) || flags.wrap).then(|| n)), (Layout::Integer(IntLayout { bytes, .. }), false) => self .to_u1024_bytes() .checked_sub(rhs.to_u1024_bytes()) .map(Number::from) .and_then(|n| n.reshaped(Layout::unsigned(n.layout().bytes()), true)) - .and_then(|mut n| (n.reshape(Layout::unsigned(bytes)) || flags.wrap).then_some(n)), + .and_then(|mut n| (n.reshape(Layout::unsigned(bytes)) || flags.wrap).then(|| n)), (Layout::Float(_), _) => panic!("integer subtraction of float numbers"), } } @@ -178,13 +178,13 @@ impl Number { .checked_mul(rhs.to_i1024_bytes()) .map(Number::from) .and_then(|n| n.reshaped(Layout::signed(n.layout().bytes()), true)) - .and_then(|mut n| (n.reshape(Layout::signed(bytes)) || flags.wrap).then_some(n)), + .and_then(|mut n| (n.reshape(Layout::signed(bytes)) || flags.wrap).then(|| n)), (Layout::Integer(IntLayout { bytes, .. }), false) => self .to_u1024_bytes() .checked_mul(rhs.to_u1024_bytes()) .map(Number::from) .and_then(|n| n.reshaped(Layout::unsigned(n.layout().bytes()), true)) - .and_then(|mut n| (n.reshape(Layout::unsigned(bytes)) || flags.wrap).then_some(n)), + .and_then(|mut n| (n.reshape(Layout::unsigned(bytes)) || flags.wrap).then(|| n)), (Layout::Float(_), _) => panic!("integer multiplication of float numbers"), } } diff --git a/src/data/number.rs b/src/data/number.rs index 08e432d..6047f0a 100644 --- a/src/data/number.rs +++ b/src/data/number.rs @@ -872,7 +872,7 @@ impl Number { /// Transformed number as an optional - or `None` if the operation was impossible without /// discarding bit information and `wrap` is set to false. pub fn reshaped(mut self, to: Layout, wrap: bool) -> Option { - self.reshape(to).then_some(self).or(if wrap { Some(self) } else { None }) + self.reshape(to).then(|| self).or(if wrap { Some(self) } else { None }) } #[doc(hidden)] diff --git a/src/lib.rs b/src/lib.rs index 939477d..500d7b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -113,6 +113,9 @@ //! //! [AluVM]: https://github.com/internet2-org/aluvm-spec +// TODO: Remove this once MSRV >= 1.62 +#![allow(clippy::unnecessary_lazy_evaluations)] + // TODO(#6) Complete string operations // TODO(#7) Complete assembly compiler for string operations // TODO(#8) Implement operations on Edwards curves