We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 64c812a commit 39e1c28Copy full SHA for 39e1c28
src/wasm.rs
@@ -70,6 +70,25 @@ impl Instant {
70
pub fn elapsed(&self) -> Duration {
71
Instant::now() - *self
72
}
73
+
74
+ pub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration> {
75
+ match self.cmp(&earlier) {
76
+ Ordering::Less => None,
77
+ _ => Some(self.duration_since(earlier)),
78
+ }
79
80
81
+ pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
82
+ self.checked_duration_since(earlier).unwrap_or_default()
83
84
85
+ pub fn checked_add(&self, duration: Duration) -> Option<Instant> {
86
+ Some(*self + duration)
87
88
89
+ pub fn checked_sub(&self, duration: Duration) -> Option<Instant> {
90
+ Some(*self - duration)
91
92
93
94
impl Add<Duration> for Instant {
0 commit comments