Skip to content

Commit 25d48ee

Browse files
authored
Merge pull request #1625 from CosmWasm/timestamp-must_use
Add #[must_use] annotations to Timestamp math functions
2 parents 8950461 + 28b2e25 commit 25d48ee

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to
1010

1111
- cosmwasm-std: Add an IBC querier implementation to `testing::MockQuerier`
1212
([#1620], [#1624]).
13+
- cosmwasm-std: Add `#[must_use]` annotations to `Timestamp` math functions.
1314

1415
[#1620]: https://github.com/CosmWasm/cosmwasm/pull/1620
1516
[#1624]: https://github.com/CosmWasm/cosmwasm/pull/1624

packages/std/src/timestamp.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,23 @@ impl Timestamp {
3838
Timestamp(Uint64::new(seconds_since_epoch * 1_000_000_000))
3939
}
4040

41+
#[must_use = "this returns the result of the operation, without modifying the original"]
4142
pub const fn plus_seconds(&self, addition: u64) -> Timestamp {
4243
self.plus_nanos(addition * 1_000_000_000)
4344
}
4445

46+
#[must_use = "this returns the result of the operation, without modifying the original"]
4547
pub const fn plus_nanos(&self, addition: u64) -> Timestamp {
4648
let nanos = Uint64::new(self.0.u64() + addition);
4749
Timestamp(nanos)
4850
}
4951

52+
#[must_use = "this returns the result of the operation, without modifying the original"]
5053
pub const fn minus_seconds(&self, subtrahend: u64) -> Timestamp {
5154
self.minus_nanos(subtrahend * 1_000_000_000)
5255
}
5356

57+
#[must_use = "this returns the result of the operation, without modifying the original"]
5458
pub const fn minus_nanos(&self, subtrahend: u64) -> Timestamp {
5559
let nanos = Uint64::new(self.0.u64() - subtrahend);
5660
Timestamp(nanos)

0 commit comments

Comments
 (0)