From 1ccad16231f58b09f127e679d54162acbc2f0dae Mon Sep 17 00:00:00 2001 From: Linus Färnstrand Date: Fri, 22 Mar 2019 22:14:35 +0100 Subject: Update sys::time impls to have checked_sub_instant --- src/libstd/sys/redox/time.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/libstd/sys/redox') diff --git a/src/libstd/sys/redox/time.rs b/src/libstd/sys/redox/time.rs index 9db3e85ca9c..881ad5c0aeb 100644 --- a/src/libstd/sys/redox/time.rs +++ b/src/libstd/sys/redox/time.rs @@ -137,10 +137,8 @@ impl Instant { false } - pub fn sub_instant(&self, other: &Instant) -> Duration { - self.t.sub_timespec(&other.t).unwrap_or_else(|_| { - panic!("specified instant was later than self") - }) + pub fn checked_sub_instant(&self, other: &Instant) -> Option { + self.t.sub_timespec(&other.t).ok() } pub fn checked_add_duration(&self, other: &Duration) -> Option { -- cgit 1.4.1-3-g733a5