Skip to content

Commit

Permalink
force panic in Add operator
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Mar 31, 2021
1 parent e005f15 commit 6f81c24
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/std/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,27 +324,27 @@ impl ops::Add<Uint128> for Uint128 {
type Output = Self;

fn add(self, rhs: Self) -> Self {
Uint128(self.u128() + rhs.u128())
Uint128(self.u128().checked_add(rhs.u128()).unwrap())
}
}

impl<'a> ops::Add<&'a Uint128> for Uint128 {
type Output = Self;

fn add(self, rhs: &'a Uint128) -> Self {
Uint128(self.u128() + rhs.u128())
Uint128(self.u128().checked_add(rhs.u128()).unwrap())
}
}

impl ops::AddAssign<Uint128> for Uint128 {
fn add_assign(&mut self, rhs: Uint128) {
self.0 += rhs.u128();
self.0 = self.0.checked_add(rhs.u128()).unwrap();
}
}

impl<'a> ops::AddAssign<&'a Uint128> for Uint128 {
fn add_assign(&mut self, rhs: &'a Uint128) {
self.0 += rhs.u128();
self.0 = self.0.checked_add(rhs.u128()).unwrap();
}
}

Expand Down

0 comments on commit 6f81c24

Please sign in to comment.