Skip to content

Commit

Permalink
Fix prelude0421 (#775)
Browse files Browse the repository at this point in the history
* add arithmetic test

* optimize code
  • Loading branch information
honeywest authored Apr 21, 2021
1 parent c2e43fc commit 5571724
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions crates/env/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions crates/primitives/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,27 +202,27 @@ impl Add<u64> for Key {
}
}

impl<'a> Add<u64> for &'a Key {
impl Add<u64> for &Key {
type Output = Key;

fn add(self, rhs: u64) -> Self::Output {
<Key as Add<u64>>::add(*self, rhs)
}
}

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 {
<Key as Add<u64>>::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<u64>>::add(self, *rhs)
fn add(self, rhs: &u64) -> Self::Output {
<&Key as Add<u64>>::add(self, *rhs)
}
}

Expand Down

0 comments on commit 5571724

Please sign in to comment.