Skip to content

Commit

Permalink
Rollup merge of rust-lang#62860 - vi:stabilize_checked_duration_since…
Browse files Browse the repository at this point in the history
…, r=alexcrichton

Stabilize checked_duration_since for 1.38.0

Looks like it has already found some use in projects.

Resolves rust-lang#58402.
  • Loading branch information
Centril authored Aug 9, 2019
2 parents ba86733 + 01d9e57 commit 1b3e7fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@
#![feature(cfg_target_has_atomic)]
#![feature(cfg_target_thread_local)]
#![feature(char_error_internals)]
#![feature(checked_duration_since)]
#![feature(clamp)]
#![feature(compiler_builtins_lib)]
#![feature(concat_idents)]
Expand Down
6 changes: 2 additions & 4 deletions src/libstd/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ impl Instant {
/// # Examples
///
/// ```no_run
/// #![feature(checked_duration_since)]
/// use std::time::{Duration, Instant};
/// use std::thread::sleep;
///
Expand All @@ -231,7 +230,7 @@ impl Instant {
/// println!("{:?}", new_now.checked_duration_since(now));
/// println!("{:?}", now.checked_duration_since(new_now)); // None
/// ```
#[unstable(feature = "checked_duration_since", issue = "58402")]
#[stable(feature = "checked_duration_since", since = "1.38.0")]
pub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration> {
self.0.checked_sub_instant(&earlier.0)
}
Expand All @@ -242,7 +241,6 @@ impl Instant {
/// # Examples
///
/// ```no_run
/// #![feature(checked_duration_since)]
/// use std::time::{Duration, Instant};
/// use std::thread::sleep;
///
Expand All @@ -252,7 +250,7 @@ impl Instant {
/// println!("{:?}", new_now.saturating_duration_since(now));
/// println!("{:?}", now.saturating_duration_since(new_now)); // 0ns
/// ```
#[unstable(feature = "checked_duration_since", issue = "58402")]
#[stable(feature = "checked_duration_since", since = "1.38.0")]
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration {
self.checked_duration_since(earlier).unwrap_or(Duration::new(0, 0))
}
Expand Down

0 comments on commit 1b3e7fb

Please sign in to comment.