Skip to content

Commit

Permalink
chore: fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 31, 2024
1 parent 3b898f2 commit e98795e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/data/arithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
}
Expand All @@ -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"),
}
}
Expand All @@ -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"),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/data/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Number> {
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)]
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e98795e

Please sign in to comment.