Skip to content

Commit bbb788d

Browse files
committed
Add #[inline] annotations to plus_seconds/minus_seconds
1 parent a74aba0 commit bbb788d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/std/src/timestamp.rs

+4
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ impl Timestamp {
5656
}
5757

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

6364
#[must_use = "this returns the result of the operation, without modifying the original"]
65+
// no #[inline] here as this could be shared with all the callers
6466
pub const fn plus_nanos(&self, addition: u64) -> Timestamp {
6567
let nanos = Uint64::new(self.0.u64() + addition);
6668
Timestamp(nanos)
@@ -101,6 +103,7 @@ impl Timestamp {
101103
///
102104
/// Panics if the result is not >= 0. I.e. times before epoch cannot be represented.
103105
#[must_use = "this returns the result of the operation, without modifying the original"]
106+
#[inline]
104107
pub const fn minus_seconds(&self, subtrahend: u64) -> Timestamp {
105108
self.minus_nanos(subtrahend * 1_000_000_000)
106109
}
@@ -110,6 +113,7 @@ impl Timestamp {
110113
///
111114
/// Panics if the result is not >= 0. I.e. times before epoch cannot be represented.
112115
#[must_use = "this returns the result of the operation, without modifying the original"]
116+
// no #[inline] here as this could be shared with all the callers
113117
pub const fn minus_nanos(&self, subtrahend: u64) -> Timestamp {
114118
Timestamp(self.0.panicking_sub(Uint64::new(subtrahend)))
115119
}

0 commit comments

Comments
 (0)