about summary refs log tree commit diff
path: root/src/libstd/sys/wasm
diff options
context:
space:
mode:
authorLinus Färnstrand <faern@faern.net>2018-12-04 02:29:57 +0100
committerLinus Färnstrand <faern@faern.net>2018-12-13 15:25:14 +0100
commit13f0463a195832f10f0f22105ad14e6d6b2eff59 (patch)
treeaa93f5e194b0d3a8d74072cee40bdc0b8cbaa5a6 /src/libstd/sys/wasm
parent9fe5cb5342244a716055fa0162e795deabd4985c (diff)
downloadrust-13f0463a195832f10f0f22105ad14e6d6b2eff59.tar.gz
rust-13f0463a195832f10f0f22105ad14e6d6b2eff59.zip
Add checked_add method to Instant time type
Diffstat (limited to 'src/libstd/sys/wasm')
-rw-r--r--src/libstd/sys/wasm/time.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/libstd/sys/wasm/time.rs b/src/libstd/sys/wasm/time.rs
index 991e8176edf..20cd870919c 100644
--- a/src/libstd/sys/wasm/time.rs
+++ b/src/libstd/sys/wasm/time.rs
@@ -28,8 +28,8 @@ impl Instant {
         self.0 - other.0
     }
 
-    pub fn add_duration(&self, other: &Duration) -> Instant {
-        Instant(self.0 + *other)
+    pub fn checked_add_duration(&self, other: &Duration) -> Option<Instant> {
+        self.0.checked_add(*other).map(|d| Instant(d))
     }
 
     pub fn sub_duration(&self, other: &Duration) -> Instant {
@@ -47,10 +47,6 @@ impl SystemTime {
         self.0.checked_sub(other.0).ok_or_else(|| other.0 - self.0)
     }
 
-    pub fn add_duration(&self, other: &Duration) -> SystemTime {
-        SystemTime(self.0 + *other)
-    }
-
     pub fn checked_add_duration(&self, other: &Duration) -> Option<SystemTime> {
         self.0.checked_add(*other).map(|d| SystemTime(d))
     }