From 7ea3450bae172e987f5d38546d1c67ba3cff2510 Mon Sep 17 00:00:00 2001 From: "Dr. Maxim Orlovsky" Date: Tue, 27 Dec 2022 12:42:07 +0100 Subject: [PATCH] Revert MSRV-breaking clippy changes --- src/data/arithm.rs | 12 ++++++------ src/data/number.rs | 2 +- src/lib.rs | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) 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