From e98795e93bd73e503e869bd93bc32310fef8cb5a Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 31 Oct 2024 13:18:20 +0100 Subject: [PATCH] chore: fix clippy --- src/data/arithm.rs | 12 ++++++------ src/data/number.rs | 2 +- src/lib.rs | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/data/arithm.rs b/src/data/arithm.rs index df44e16..a680e09 100644 --- a/src/data/arithm.rs +++ b/src/data/arithm.rs @@ -135,13 +135,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(|| n)), + .and_then(|mut n| (n.reshape(Layout::signed(bytes)) || flags.wrap).then_some(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(|| n)), + .and_then(|mut n| (n.reshape(Layout::unsigned(bytes)) || flags.wrap).then_some(n)), (Layout::Float(_), _) => panic!("integer addition of float numbers"), } } @@ -163,13 +163,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(|| n)), + .and_then(|mut n| (n.reshape(Layout::signed(bytes)) || flags.wrap).then_some(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(|| n)), + .and_then(|mut n| (n.reshape(Layout::unsigned(bytes)) || flags.wrap).then_some(n)), (Layout::Float(_), _) => panic!("integer subtraction of float numbers"), } } @@ -191,13 +191,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(|| n)), + .and_then(|mut n| (n.reshape(Layout::signed(bytes)) || flags.wrap).then_some(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(|| n)), + .and_then(|mut n| (n.reshape(Layout::unsigned(bytes)) || flags.wrap).then_some(n)), (Layout::Float(_), _) => panic!("integer multiplication of float numbers"), } } diff --git a/src/data/number.rs b/src/data/number.rs index 3382e46..0aea924 100644 --- a/src/data/number.rs +++ b/src/data/number.rs @@ -1126,7 +1126,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(|| self).or(if wrap { Some(self) } else { None }) + self.reshape(to).then_some(self).or(if wrap { Some(self) } else { None }) } #[doc(hidden)] diff --git a/src/lib.rs b/src/lib.rs index 42cfaa7..966d792 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -136,8 +136,7 @@ //! //! [AluVM]: https://github.com/internet2-org/aluvm-spec -// TODO: Remove this once MSRV >= 1.62 -#![allow(clippy::unnecessary_lazy_evaluations)] +#![allow(clippy::bool_assert_comparison)] // TODO(#6) Complete string operations // TODO(#7) Complete assembly compiler for string operations