Auto merge of #46666 - clarcharr:duration_core, r=alexcrichton
Move Duration to libcore Fixes #46520; should be merged after #46508.
This commit is contained in:
@@ -168,6 +168,7 @@ pub mod slice;
|
|||||||
pub mod str;
|
pub mod str;
|
||||||
pub mod hash;
|
pub mod hash;
|
||||||
pub mod fmt;
|
pub mod fmt;
|
||||||
|
pub mod time;
|
||||||
|
|
||||||
// note: does not need to be public
|
// note: does not need to be public
|
||||||
mod char_private;
|
mod char_private;
|
||||||
|
|||||||
@@ -7,6 +7,19 @@
|
|||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
#![stable(feature = "duration_core", since = "1.24.0")]
|
||||||
|
|
||||||
|
//! Temporal quantification.
|
||||||
|
//!
|
||||||
|
//! Example:
|
||||||
|
//!
|
||||||
|
//! ```
|
||||||
|
//! use std::time::Duration;
|
||||||
|
//!
|
||||||
|
//! let five_seconds = Duration::new(5, 0);
|
||||||
|
//! // both declarations are equivalent
|
||||||
|
//! assert_eq!(Duration::new(5, 0), Duration::from_secs(5));
|
||||||
|
//! ```
|
||||||
|
|
||||||
use iter::Sum;
|
use iter::Sum;
|
||||||
use ops::{Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign};
|
use ops::{Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign};
|
||||||
@@ -45,7 +58,7 @@ const MICROS_PER_SEC: u64 = 1_000_000;
|
|||||||
///
|
///
|
||||||
/// let ten_millis = Duration::from_millis(10);
|
/// let ten_millis = Duration::from_millis(10);
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "duration", since = "1.3.0")]
|
#[stable(feature = "duration_core", since = "1.24.0")]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, Default)]
|
||||||
pub struct Duration {
|
pub struct Duration {
|
||||||
secs: u64,
|
secs: u64,
|
||||||
@@ -29,9 +29,7 @@ use sys::time;
|
|||||||
use sys_common::FromInner;
|
use sys_common::FromInner;
|
||||||
|
|
||||||
#[stable(feature = "time", since = "1.3.0")]
|
#[stable(feature = "time", since = "1.3.0")]
|
||||||
pub use self::duration::Duration;
|
pub use core::time::Duration;
|
||||||
|
|
||||||
mod duration;
|
|
||||||
|
|
||||||
/// A measurement of a monotonically nondecreasing clock.
|
/// A measurement of a monotonically nondecreasing clock.
|
||||||
/// Opaque and useful only with `Duration`.
|
/// Opaque and useful only with `Duration`.
|
||||||
Reference in New Issue
Block a user