Skip to content

Commit 8231831

Browse files
committed
Rename checked_add_duration to checked_add and make it take the duration by value
1 parent 166f7d9 commit 8231831

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libstd/time.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ impl SystemTime {
361361
/// Returns `Some(t)` where `t` is the time `self + duration` if `t` can be represented as
362362
/// `SystemTime` (which means it's inside the bounds of the underlying data structure), `None`
363363
/// otherwise.
364-
#[stable(feature = "time_checked_add", since = "1.32.0")]
365-
pub fn checked_add_duration(&self, duration: &Duration) -> Option<SystemTime> {
366-
self.0.checked_add_duration(duration).map(|t| SystemTime(t))
364+
#[unstable(feature = "time_checked_add", issue = "55940")]
365+
pub fn checked_add(&self, duration: Duration) -> Option<SystemTime> {
366+
self.0.checked_add_duration(&duration).map(|t| SystemTime(t))
367367
}
368368
}
369369

@@ -571,13 +571,13 @@ mod tests {
571571
let max_duration = Duration::from_secs(u64::max_value());
572572
// in case `SystemTime` can store `>= UNIX_EPOCH + max_duration`.
573573
for _ in 0..2 {
574-
maybe_t = maybe_t.and_then(|t| t.checked_add_duration(&max_duration));
574+
maybe_t = maybe_t.and_then(|t| t.checked_add(max_duration));
575575
}
576576
assert_eq!(maybe_t, None);
577577

578578
// checked_add_duration calculates the right time and will work for another year
579579
let year = Duration::from_secs(60 * 60 * 24 * 365);
580-
assert_eq!(a + year, a.checked_add_duration(&year).unwrap());
580+
assert_eq!(a + year, a.checked_add(year).unwrap());
581581
}
582582

583583
#[test]

0 commit comments

Comments
 (0)