From 5571724fa79cf94608ea915aa6690a7d98ba4513 Mon Sep 17 00:00:00 2001 From: honeywest <50997103+honeywest@users.noreply.github.com> Date: Wed, 21 Apr 2021 17:32:36 +0800 Subject: [PATCH] Fix prelude0421 (#775) * add arithmetic test * optimize code --- crates/env/src/arithmetic.rs | 4 ++++ crates/primitives/src/key.rs | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/env/src/arithmetic.rs b/crates/env/src/arithmetic.rs index e3038376215..131cfd44aa6 100644 --- a/crates/env/src/arithmetic.rs +++ b/crates/env/src/arithmetic.rs @@ -218,6 +218,10 @@ mod tests { u64::max_value(), Saturating::saturating_mul(u64::max_value(), 2) ); + assert_eq!( + i64::max_value(), + Saturating::saturating_mul(i64::max_value(), 2) + ); assert_eq!( i64::min_value(), Saturating::saturating_mul(i64::min_value(), 2) diff --git a/crates/primitives/src/key.rs b/crates/primitives/src/key.rs index 3b1878ad2de..d215f6f8cab 100644 --- a/crates/primitives/src/key.rs +++ b/crates/primitives/src/key.rs @@ -202,7 +202,7 @@ impl Add for Key { } } -impl<'a> Add for &'a Key { +impl Add for &Key { type Output = Key; fn add(self, rhs: u64) -> Self::Output { @@ -210,19 +210,19 @@ impl<'a> Add for &'a Key { } } -impl<'a> Add<&'a u64> for Key { +impl Add<&u64> for Key { type Output = Key; - fn add(self, rhs: &'a u64) -> Self::Output { + fn add(self, rhs: &u64) -> Self::Output { >::add(self, *rhs) } } -impl<'a, 'b> Add<&'b u64> for &'a Key { +impl Add<&u64> for &Key { type Output = Key; - fn add(self, rhs: &'b u64) -> Self::Output { - <&'a Key as Add>::add(self, *rhs) + fn add(self, rhs: &u64) -> Self::Output { + <&Key as Add>::add(self, *rhs) } }