diff options
| author | Linus Färnstrand <faern@faern.net> | 2018-12-11 00:49:32 +0100 |
|---|---|---|
| committer | Linus Färnstrand <faern@faern.net> | 2018-12-13 15:25:14 +0100 |
| commit | 9511fc7845f108e2af47f9c2b07544a63c2f1ec1 (patch) | |
| tree | 48a2d587e9f61c86b00f446ce6e05b36a133929e /src/libstd/sys | |
| parent | f5a99c321b14e69e9d9a6ffaac3a5b7b8906c1f2 (diff) | |
| download | rust-9511fc7845f108e2af47f9c2b07544a63c2f1ec1.tar.gz rust-9511fc7845f108e2af47f9c2b07544a63c2f1ec1.zip | |
Fix checked_add/sub for sys/sgx/time.rs
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/sgx/time.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/libstd/sys/sgx/time.rs b/src/libstd/sys/sgx/time.rs index b01c992768e..196e1a97fc4 100644 --- a/src/libstd/sys/sgx/time.rs +++ b/src/libstd/sys/sgx/time.rs @@ -28,12 +28,12 @@ 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> { + Some(Instant(self.0.checked_add(*other)?)) } - pub fn sub_duration(&self, other: &Duration) -> Instant { - Instant(self.0 - *other) + pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> { + Some(Instant(self.0.checked_sub(*other)?)) } } @@ -47,15 +47,11 @@ 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)) + Some(SystemTime(self.0.checked_add(*other)?)) } - pub fn sub_duration(&self, other: &Duration) -> SystemTime { - SystemTime(self.0 - *other) + pub fn checked_sub_duration(&self, other: &Duration) -> Option<SystemTime> { + Some(SystemTime(self.0.checked_sub(*other)?)) } } |
