diff --git a/nanvm-lib/src/big_numbers/big_uint.rs b/nanvm-lib/src/big_numbers/big_uint.rs index 3fc5b2fa..a4746208 100644 --- a/nanvm-lib/src/big_numbers/big_uint.rs +++ b/nanvm-lib/src/big_numbers/big_uint.rs @@ -249,7 +249,7 @@ impl Mul for &BigUint { let mut value = new_resize(total_max + 1); let mut i: usize = 0; while i < total_max { - let mut j = if i > rhs_max { i - rhs_max } else { 0 }; + let mut j = i.saturating_sub(rhs_max); let max = if i < lhs_max { i } else { lhs_max }; while j <= max { value = add_to_vec(value, i, self.value[j] as u128 * other.value[i - j] as u128); diff --git a/nanvm-lib/src/js/js_bigint.rs b/nanvm-lib/src/js/js_bigint.rs index ab1aea98..8d86358c 100644 --- a/nanvm-lib/src/js/js_bigint.rs +++ b/nanvm-lib/src/js/js_bigint.rs @@ -184,7 +184,7 @@ fn mul_vec(lhs: &[u64], rhs: &[u64]) -> Vec { let mut vec = new_resize(total_max + 1); let mut i: usize = 0; while i < total_max { - let mut j = if i > rhs_max { i - rhs_max } else { 0 }; + let mut j = i.saturating_sub(rhs_max); let max = if i < lhs_max { i } else { lhs_max }; while j <= max { vec = add_to_vec(vec, i, lhs[j] as u128 * rhs[i - j] as u128); @@ -378,7 +378,7 @@ pub fn equals(lhs: &JsBigint, rhs: &JsBigint) -> bool { if lhs.sign() != rhs.sign() { return false; } - return cmp_vec(lhs.items(), rhs.items()) == Ordering::Equal; + cmp_vec(lhs.items(), rhs.items()) == Ordering::Equal } fn to_twos_complement(value: &JsBigint) -> TwosComplement { diff --git a/nanvm-lib/src/mem/arena.rs b/nanvm-lib/src/mem/arena.rs index 62ae6964..f2554e4b 100644 --- a/nanvm-lib/src/mem/arena.rs +++ b/nanvm-lib/src/mem/arena.rs @@ -34,13 +34,13 @@ impl BlockHeader for NoHeader { } } -impl<'a> Dealloc for &Arena<'a> { +impl Dealloc for &Arena<'_> { type BlockHeader = NoHeader; #[inline(always)] unsafe fn dealloc(_: *mut u8, _: Layout) {} } -impl<'a> Manager for &Arena<'a> { +impl Manager for &Arena<'_> { type Dealloc = Self; unsafe fn alloc(self, layout: Layout) -> *mut u8 { let result = {