From f841ff4a7b8227f17e0fa056c6a73ba549f2872e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 31 Jan 2019 20:46:11 +0100 Subject: [PATCH 1/2] Stabilize the time_checked_add feature --- src/libstd/time.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 23924559fcc24..6685ee202658a 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -245,7 +245,7 @@ impl Instant { /// Returns `Some(t)` where `t` is the time `self + duration` if `t` can be represented as /// `Instant` (which means it's inside the bounds of the underlying data structure), `None` /// otherwise. - #[unstable(feature = "time_checked_add", issue = "55940")] + #[stable(feature = "time_checked_add", since = "1.34.0")] pub fn checked_add(&self, duration: Duration) -> Option { self.0.checked_add_duration(&duration).map(|t| Instant(t)) } @@ -253,7 +253,7 @@ impl Instant { /// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as /// `Instant` (which means it's inside the bounds of the underlying data structure), `None` /// otherwise. - #[unstable(feature = "time_checked_add", issue = "55940")] + #[stable(feature = "time_checked_add", since = "1.34.0")] pub fn checked_sub(&self, duration: Duration) -> Option { self.0.checked_sub_duration(&duration).map(|t| Instant(t)) } @@ -418,7 +418,7 @@ impl SystemTime { /// Returns `Some(t)` where `t` is the time `self + duration` if `t` can be represented as /// `SystemTime` (which means it's inside the bounds of the underlying data structure), `None` /// otherwise. - #[unstable(feature = "time_checked_add", issue = "55940")] + #[stable(feature = "time_checked_add", since = "1.34.0")] pub fn checked_add(&self, duration: Duration) -> Option { self.0.checked_add_duration(&duration).map(|t| SystemTime(t)) } @@ -426,7 +426,7 @@ impl SystemTime { /// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as /// `SystemTime` (which means it's inside the bounds of the underlying data structure), `None` /// otherwise. - #[unstable(feature = "time_checked_add", issue = "55940")] + #[stable(feature = "time_checked_add", since = "1.34.0")] pub fn checked_sub(&self, duration: Duration) -> Option { self.0.checked_sub_duration(&duration).map(|t| SystemTime(t)) } From 2f2d49523a8a2cd4e3156dc2f810a83ef37e1872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 31 Jan 2019 23:18:07 +0100 Subject: [PATCH 2/2] Simplify lambdas --- src/libstd/time.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 6685ee202658a..b63d816ce44ca 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -247,7 +247,7 @@ impl Instant { /// otherwise. #[stable(feature = "time_checked_add", since = "1.34.0")] pub fn checked_add(&self, duration: Duration) -> Option { - self.0.checked_add_duration(&duration).map(|t| Instant(t)) + self.0.checked_add_duration(&duration).map(Instant) } /// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as @@ -255,7 +255,7 @@ impl Instant { /// otherwise. #[stable(feature = "time_checked_add", since = "1.34.0")] pub fn checked_sub(&self, duration: Duration) -> Option { - self.0.checked_sub_duration(&duration).map(|t| Instant(t)) + self.0.checked_sub_duration(&duration).map(Instant) } } @@ -420,7 +420,7 @@ impl SystemTime { /// otherwise. #[stable(feature = "time_checked_add", since = "1.34.0")] pub fn checked_add(&self, duration: Duration) -> Option { - self.0.checked_add_duration(&duration).map(|t| SystemTime(t)) + self.0.checked_add_duration(&duration).map(SystemTime) } /// Returns `Some(t)` where `t` is the time `self - duration` if `t` can be represented as @@ -428,7 +428,7 @@ impl SystemTime { /// otherwise. #[stable(feature = "time_checked_add", since = "1.34.0")] pub fn checked_sub(&self, duration: Duration) -> Option { - self.0.checked_sub_duration(&duration).map(|t| SystemTime(t)) + self.0.checked_sub_duration(&duration).map(SystemTime) } }