We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 64c812a commit 3aee2c2Copy full SHA for 3aee2c2
src/wasm.rs
@@ -70,6 +70,26 @@ 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
+ let since = self.duration_since(earlier);
76
+ if since >= 0 {
77
+ return Some(Since);
78
+ }
79
+ None
80
81
82
+ pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
83
+ self.checked_duration_since(earlier).unwrap_or_default()
84
85
86
+ pub fn checked_add(&self, duration: Duration) -> Option<Instant> {
87
+ Some(*self + duration)
88
89
90
+ pub fn checked_sub(&self, duration: Duration) -> Option<Instant> {
91
+ Some(*self - duration)
92
93
94
95
impl Add<Duration> for Instant {
0 commit comments