Skip to content

Commit

Permalink
Merge pull request #1831 from CosmWasm/abs-diff-const
Browse files Browse the repository at this point in the history
Make abs_diff const for all integers
  • Loading branch information
webmaster128 authored Aug 22, 2023
2 parents c16d31a + 0688df7 commit 2543067
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to

- cosmwasm-std: Implement `Not` for `Uint{64,128,256}` ([#1799]).
- cosmwasm-std: Add iterators for `Coins` ([#1806]).
- cosmwasm-std: Make `abs_diff` const for `Uint{256,512}` and
`Int{64,128,256,512}`. It is now const for all integer types.

[#1799]: https://github.com/CosmWasm/cosmwasm/pull/1799
[#1806]: https://github.com/CosmWasm/cosmwasm/pull/1806
Expand Down
2 changes: 1 addition & 1 deletion packages/std/src/math/int128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl Int128 {
}

#[must_use = "this returns the result of the operation, without modifying the original"]
pub fn abs_diff(self, other: Self) -> Uint128 {
pub const fn abs_diff(self, other: Self) -> Uint128 {
Uint128(self.0.abs_diff(other.0))
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/std/src/math/int256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl Int256 {
}

#[must_use = "this returns the result of the operation, without modifying the original"]
pub fn abs_diff(self, other: Self) -> Uint256 {
pub const fn abs_diff(self, other: Self) -> Uint256 {
Uint256(self.0.abs_diff(other.0))
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/std/src/math/int512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Int512 {
}

#[must_use = "this returns the result of the operation, without modifying the original"]
pub fn abs_diff(self, other: Self) -> Uint512 {
pub const fn abs_diff(self, other: Self) -> Uint512 {
Uint512(self.0.abs_diff(other.0))
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/std/src/math/int64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl Int64 {
}

#[must_use = "this returns the result of the operation, without modifying the original"]
pub fn abs_diff(self, other: Self) -> Uint64 {
pub const fn abs_diff(self, other: Self) -> Uint64 {
Uint64(self.0.abs_diff(other.0))
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/std/src/math/uint256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl Uint256 {
}

#[must_use = "this returns the result of the operation, without modifying the original"]
pub fn abs_diff(self, other: Self) -> Self {
pub const fn abs_diff(self, other: Self) -> Self {
Self(self.0.abs_diff(other.0))
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/std/src/math/uint512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl Uint512 {
}

#[must_use = "this returns the result of the operation, without modifying the original"]
pub fn abs_diff(self, other: Self) -> Self {
pub const fn abs_diff(self, other: Self) -> Self {
Self(self.0.abs_diff(other.0))
}
}
Expand Down

0 comments on commit 2543067

Please sign in to comment.