diff --git a/CHANGELOG.md b/CHANGELOG.md index d4aca887e9..5e7490734f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/std/src/math/int128.rs b/packages/std/src/math/int128.rs index 080236c19a..cc0b7c83b5 100644 --- a/packages/std/src/math/int128.rs +++ b/packages/std/src/math/int128.rs @@ -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)) } } diff --git a/packages/std/src/math/int256.rs b/packages/std/src/math/int256.rs index 50905713a2..5616fcc2e7 100644 --- a/packages/std/src/math/int256.rs +++ b/packages/std/src/math/int256.rs @@ -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)) } } diff --git a/packages/std/src/math/int512.rs b/packages/std/src/math/int512.rs index 08a30d0c3a..2b122418e5 100644 --- a/packages/std/src/math/int512.rs +++ b/packages/std/src/math/int512.rs @@ -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)) } } diff --git a/packages/std/src/math/int64.rs b/packages/std/src/math/int64.rs index c977ed5581..2e9ac7f68d 100644 --- a/packages/std/src/math/int64.rs +++ b/packages/std/src/math/int64.rs @@ -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)) } } diff --git a/packages/std/src/math/uint256.rs b/packages/std/src/math/uint256.rs index 2199245a75..6422dee764 100644 --- a/packages/std/src/math/uint256.rs +++ b/packages/std/src/math/uint256.rs @@ -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)) } } diff --git a/packages/std/src/math/uint512.rs b/packages/std/src/math/uint512.rs index 0300d0f76e..c4dd9e3f52 100644 --- a/packages/std/src/math/uint512.rs +++ b/packages/std/src/math/uint512.rs @@ -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)) } }