about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSebastian Geisler <sebastian@blockstream.io>2018-11-04 21:23:20 -0800
committerSebastian Geisler <sebastian@blockstream.io>2018-11-15 22:55:27 -0800
commit86ef38b3b7a24959ca11a29c79cf921ed5986bc9 (patch)
treece43b3722272137604aace188db81bea3dc52eb3
parent6d40b7232eaa00ab5c060582011f350725703a1e (diff)
downloadrust-86ef38b3b7a24959ca11a29c79cf921ed5986bc9.tar.gz
rust-86ef38b3b7a24959ca11a29c79cf921ed5986bc9.zip
Rename checked_add_duration to checked_add and make it take the duration by value
-rw-r--r--src/libstd/time.rs10
1 files 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<SystemTime> {
-        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<SystemTime> {
+        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]