Skip to content

Commit

Permalink
Merge pull request #49 from JayXon/unsigned
Browse files Browse the repository at this point in the history
Fix warning when Num is unsigned
  • Loading branch information
JayXon authored Jun 16, 2024
2 parents fd31635 + e7246a5 commit dd271e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ pub fn apply_bit_and(l: Num, r: Num) -> Option<Num> {
Some(l & r)
}
pub fn apply_bit_shl(l: Num, r: Num) -> Option<Num> {
#[allow(unused_comparisons)]
if r >= 0 && r < Num::BITS as Num {
Some(l << r)
} else {
Expand All @@ -165,6 +166,7 @@ pub fn apply_bit_shl_wrap(l: Num, r: Num) -> Option<Num> {
Some(l << r)
}
pub fn apply_bit_shr(l: Num, r: Num) -> Option<Num> {
#[allow(unused_comparisons)]
if r >= 0 {
Some(l >> r.min(Num::BITS as Num - 1))
} else {
Expand All @@ -184,6 +186,7 @@ pub fn apply_mul(l: Num, r: Num) -> Option<Num> {
Some(l * r)
}
pub fn apply_mod_floor(l: Num, r: Num) -> Option<Num> {
#[allow(unused_comparisons)]
if r == 0 || (Num::MIN < 0 && l == Num::MIN && r == !0) {
None
} else {
Expand All @@ -194,6 +197,7 @@ pub fn apply_mod_trunc(l: Num, r: Num) -> Option<Num> {
l.checked_rem(r)
}
pub fn apply_div_floor(l: Num, r: Num) -> Option<Num> {
#[allow(unused_comparisons)]
if r == 0 || (Num::MIN < 0 && l == Num::MIN && r == !0) {
None
} else {
Expand Down

0 comments on commit dd271e4

Please sign in to comment.