Skip to content

Commit

Permalink
Add #[inline] annotations to plus_seconds/minus_seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Apr 10, 2024
1 parent a74aba0 commit bbb788d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/std/src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ impl Timestamp {
}

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

#[must_use = "this returns the result of the operation, without modifying the original"]
// no #[inline] here as this could be shared with all the callers
pub const fn plus_nanos(&self, addition: u64) -> Timestamp {
let nanos = Uint64::new(self.0.u64() + addition);
Timestamp(nanos)
Expand Down Expand Up @@ -101,6 +103,7 @@ impl Timestamp {
///
/// Panics if the result is not >= 0. I.e. times before epoch cannot be represented.
#[must_use = "this returns the result of the operation, without modifying the original"]
#[inline]
pub const fn minus_seconds(&self, subtrahend: u64) -> Timestamp {
self.minus_nanos(subtrahend * 1_000_000_000)
}
Expand All @@ -110,6 +113,7 @@ impl Timestamp {
///
/// Panics if the result is not >= 0. I.e. times before epoch cannot be represented.
#[must_use = "this returns the result of the operation, without modifying the original"]
// no #[inline] here as this could be shared with all the callers
pub const fn minus_nanos(&self, subtrahend: u64) -> Timestamp {
Timestamp(self.0.panicking_sub(Uint64::new(subtrahend)))
}
Expand Down

0 comments on commit bbb788d

Please sign in to comment.