From 86ef38b3b7a24959ca11a29c79cf921ed5986bc9 Mon Sep 17 00:00:00 2001 From: Sebastian Geisler Date: Sun, 4 Nov 2018 21:23:20 -0800 Subject: [PATCH] Rename checked_add_duration to checked_add and make it take the duration by value --- src/libstd/time.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 94875d8993d..c905af442de 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -361,9 +361,9 @@ 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. - #[stable(feature = "time_checked_add", since = "1.32.0")] - pub fn checked_add_duration(&self, duration: &Duration) -> Option { - self.0.checked_add_duration(duration).map(|t| SystemTime(t)) + #[unstable(feature = "time_checked_add", issue = "55940")] + pub fn checked_add(&self, duration: Duration) -> Option { + self.0.checked_add_duration(&duration).map(|t| SystemTime(t)) } } @@ -571,13 +571,13 @@ mod tests { let max_duration = Duration::from_secs(u64::max_value()); // in case `SystemTime` can store `>= UNIX_EPOCH + max_duration`. for _ in 0..2 { - maybe_t = maybe_t.and_then(|t| t.checked_add_duration(&max_duration)); + maybe_t = maybe_t.and_then(|t| t.checked_add(max_duration)); } assert_eq!(maybe_t, None); // checked_add_duration calculates the right time and will work for another year let year = Duration::from_secs(60 * 60 * 24 * 365); - assert_eq!(a + year, a.checked_add_duration(&year).unwrap()); + assert_eq!(a + year, a.checked_add(year).unwrap()); } #[test]