Skip to content

Commit

Permalink
Add saturating_add methods
Browse files Browse the repository at this point in the history
  • Loading branch information
guidovranken committed Jan 9, 2024
1 parent 84bc698 commit a85cc2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions engine-types/src/types/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ impl Yocto {
pub const fn as_u128(self) -> u128 {
self.0
}

pub const fn saturating_add(self, rhs: Yocto) -> Yocto {
Yocto(self.0.saturating_add(rhs.0))
}
}

impl Serialize for Yocto {
Expand Down
4 changes: 4 additions & 0 deletions engine-types/src/types/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ impl NearGas {
pub const fn as_u64(self) -> u64 {
self.0
}

pub const fn saturating_add(self, rhs: NearGas) -> NearGas {
NearGas(self.0.saturating_add(rhs.0))
}
}

#[derive(
Expand Down

0 comments on commit a85cc2a

Please sign in to comment.