Add a few missing stability markers.
This commit is contained in:
parent
52c74e63da
commit
9836742d6a
4 changed files with 38 additions and 0 deletions
|
@ -46,6 +46,7 @@ use super::table::BucketState::{
|
||||||
use super::state::HashState;
|
use super::state::HashState;
|
||||||
|
|
||||||
const INITIAL_LOG2_CAP: uint = 5;
|
const INITIAL_LOG2_CAP: uint = 5;
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub const INITIAL_CAPACITY: uint = 1 << INITIAL_LOG2_CAP; // 2^5
|
pub const INITIAL_CAPACITY: uint = 1 << INITIAL_LOG2_CAP; // 2^5
|
||||||
|
|
||||||
/// The default behavior of HashMap implements a load factor of 90.9%.
|
/// The default behavior of HashMap implements a load factor of 90.9%.
|
||||||
|
@ -1596,6 +1597,8 @@ impl Default for RandomState {
|
||||||
/// typically declare an ability to explicitly hash into this particular type,
|
/// typically declare an ability to explicitly hash into this particular type,
|
||||||
/// but rather in a `H: hash::Writer` type parameter.
|
/// but rather in a `H: hash::Writer` type parameter.
|
||||||
#[allow(missing_copy_implementations)]
|
#[allow(missing_copy_implementations)]
|
||||||
|
#[unstable(feature = "std_misc",
|
||||||
|
reason = "hashing an hash maps may be altered")]
|
||||||
pub struct Hasher { inner: SipHasher }
|
pub struct Hasher { inner: SipHasher }
|
||||||
|
|
||||||
impl hash::Writer for Hasher {
|
impl hash::Writer for Hasher {
|
||||||
|
|
|
@ -24,6 +24,7 @@ use hash;
|
||||||
/// algorithm can implement the `Default` trait and create hash maps with the
|
/// algorithm can implement the `Default` trait and create hash maps with the
|
||||||
/// `DefaultState` structure. This state is 0-sized and will simply delegate
|
/// `DefaultState` structure. This state is 0-sized and will simply delegate
|
||||||
/// to `Default` when asked to create a hasher.
|
/// to `Default` when asked to create a hasher.
|
||||||
|
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
|
||||||
pub trait HashState {
|
pub trait HashState {
|
||||||
type Hasher: hash::Hasher;
|
type Hasher: hash::Hasher;
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ pub trait HashState {
|
||||||
/// default trait.
|
/// default trait.
|
||||||
///
|
///
|
||||||
/// This struct has is 0-sized and does not need construction.
|
/// This struct has is 0-sized and does not need construction.
|
||||||
|
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
|
||||||
pub struct DefaultState<H>;
|
pub struct DefaultState<H>;
|
||||||
|
|
||||||
impl<H: Default + hash::Hasher> HashState for DefaultState<H> {
|
impl<H: Default + hash::Hasher> HashState for DefaultState<H> {
|
||||||
|
|
|
@ -45,6 +45,7 @@ macro_rules! try_opt {
|
||||||
|
|
||||||
/// ISO 8601 time duration with nanosecond precision.
|
/// ISO 8601 time duration with nanosecond precision.
|
||||||
/// This also allows for the negative duration; see individual methods for details.
|
/// This also allows for the negative duration; see individual methods for details.
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||||
pub struct Duration {
|
pub struct Duration {
|
||||||
secs: i64,
|
secs: i64,
|
||||||
|
@ -52,12 +53,14 @@ pub struct Duration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The minimum possible `Duration`: `i64::MIN` milliseconds.
|
/// The minimum possible `Duration`: `i64::MIN` milliseconds.
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub const MIN: Duration = Duration {
|
pub const MIN: Duration = Duration {
|
||||||
secs: i64::MIN / MILLIS_PER_SEC - 1,
|
secs: i64::MIN / MILLIS_PER_SEC - 1,
|
||||||
nanos: NANOS_PER_SEC + (i64::MIN % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI
|
nanos: NANOS_PER_SEC + (i64::MIN % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The maximum possible `Duration`: `i64::MAX` milliseconds.
|
/// The maximum possible `Duration`: `i64::MAX` milliseconds.
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub const MAX: Duration = Duration {
|
pub const MAX: Duration = Duration {
|
||||||
secs: i64::MAX / MILLIS_PER_SEC,
|
secs: i64::MAX / MILLIS_PER_SEC,
|
||||||
nanos: (i64::MAX % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI
|
nanos: (i64::MAX % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI
|
||||||
|
@ -68,6 +71,7 @@ impl Duration {
|
||||||
/// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks.
|
/// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks.
|
||||||
/// Panics when the duration is out of bounds.
|
/// Panics when the duration is out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn weeks(weeks: i64) -> Duration {
|
pub fn weeks(weeks: i64) -> Duration {
|
||||||
let secs = weeks.checked_mul(SECS_PER_WEEK).expect("Duration::weeks out of bounds");
|
let secs = weeks.checked_mul(SECS_PER_WEEK).expect("Duration::weeks out of bounds");
|
||||||
Duration::seconds(secs)
|
Duration::seconds(secs)
|
||||||
|
@ -77,6 +81,7 @@ impl Duration {
|
||||||
/// Equivalent to `Duration::seconds(days * 24 * 60 * 60)` with overflow checks.
|
/// Equivalent to `Duration::seconds(days * 24 * 60 * 60)` with overflow checks.
|
||||||
/// Panics when the duration is out of bounds.
|
/// Panics when the duration is out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn days(days: i64) -> Duration {
|
pub fn days(days: i64) -> Duration {
|
||||||
let secs = days.checked_mul(SECS_PER_DAY).expect("Duration::days out of bounds");
|
let secs = days.checked_mul(SECS_PER_DAY).expect("Duration::days out of bounds");
|
||||||
Duration::seconds(secs)
|
Duration::seconds(secs)
|
||||||
|
@ -86,6 +91,7 @@ impl Duration {
|
||||||
/// Equivalent to `Duration::seconds(hours * 60 * 60)` with overflow checks.
|
/// Equivalent to `Duration::seconds(hours * 60 * 60)` with overflow checks.
|
||||||
/// Panics when the duration is out of bounds.
|
/// Panics when the duration is out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn hours(hours: i64) -> Duration {
|
pub fn hours(hours: i64) -> Duration {
|
||||||
let secs = hours.checked_mul(SECS_PER_HOUR).expect("Duration::hours ouf of bounds");
|
let secs = hours.checked_mul(SECS_PER_HOUR).expect("Duration::hours ouf of bounds");
|
||||||
Duration::seconds(secs)
|
Duration::seconds(secs)
|
||||||
|
@ -95,6 +101,7 @@ impl Duration {
|
||||||
/// Equivalent to `Duration::seconds(minutes * 60)` with overflow checks.
|
/// Equivalent to `Duration::seconds(minutes * 60)` with overflow checks.
|
||||||
/// Panics when the duration is out of bounds.
|
/// Panics when the duration is out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn minutes(minutes: i64) -> Duration {
|
pub fn minutes(minutes: i64) -> Duration {
|
||||||
let secs = minutes.checked_mul(SECS_PER_MINUTE).expect("Duration::minutes out of bounds");
|
let secs = minutes.checked_mul(SECS_PER_MINUTE).expect("Duration::minutes out of bounds");
|
||||||
Duration::seconds(secs)
|
Duration::seconds(secs)
|
||||||
|
@ -104,6 +111,7 @@ impl Duration {
|
||||||
/// Panics when the duration is more than `i64::MAX` milliseconds
|
/// Panics when the duration is more than `i64::MAX` milliseconds
|
||||||
/// or less than `i64::MIN` milliseconds.
|
/// or less than `i64::MIN` milliseconds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn seconds(seconds: i64) -> Duration {
|
pub fn seconds(seconds: i64) -> Duration {
|
||||||
let d = Duration { secs: seconds, nanos: 0 };
|
let d = Duration { secs: seconds, nanos: 0 };
|
||||||
if d < MIN || d > MAX {
|
if d < MIN || d > MAX {
|
||||||
|
@ -114,6 +122,7 @@ impl Duration {
|
||||||
|
|
||||||
/// Makes a new `Duration` with given number of milliseconds.
|
/// Makes a new `Duration` with given number of milliseconds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn milliseconds(milliseconds: i64) -> Duration {
|
pub fn milliseconds(milliseconds: i64) -> Duration {
|
||||||
let (secs, millis) = div_mod_floor_64(milliseconds, MILLIS_PER_SEC);
|
let (secs, millis) = div_mod_floor_64(milliseconds, MILLIS_PER_SEC);
|
||||||
let nanos = millis as i32 * NANOS_PER_MILLI;
|
let nanos = millis as i32 * NANOS_PER_MILLI;
|
||||||
|
@ -122,6 +131,7 @@ impl Duration {
|
||||||
|
|
||||||
/// Makes a new `Duration` with given number of microseconds.
|
/// Makes a new `Duration` with given number of microseconds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn microseconds(microseconds: i64) -> Duration {
|
pub fn microseconds(microseconds: i64) -> Duration {
|
||||||
let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC);
|
let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC);
|
||||||
let nanos = micros as i32 * NANOS_PER_MICRO;
|
let nanos = micros as i32 * NANOS_PER_MICRO;
|
||||||
|
@ -130,6 +140,7 @@ impl Duration {
|
||||||
|
|
||||||
/// Makes a new `Duration` with given number of nanoseconds.
|
/// Makes a new `Duration` with given number of nanoseconds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn nanoseconds(nanos: i64) -> Duration {
|
pub fn nanoseconds(nanos: i64) -> Duration {
|
||||||
let (secs, nanos) = div_mod_floor_64(nanos, NANOS_PER_SEC as i64);
|
let (secs, nanos) = div_mod_floor_64(nanos, NANOS_PER_SEC as i64);
|
||||||
Duration { secs: secs, nanos: nanos as i32 }
|
Duration { secs: secs, nanos: nanos as i32 }
|
||||||
|
@ -137,6 +148,7 @@ impl Duration {
|
||||||
|
|
||||||
/// Runs a closure, returning the duration of time it took to run the
|
/// Runs a closure, returning the duration of time it took to run the
|
||||||
/// closure.
|
/// closure.
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn span<F>(f: F) -> Duration where F: FnOnce() {
|
pub fn span<F>(f: F) -> Duration where F: FnOnce() {
|
||||||
let before = super::precise_time_ns();
|
let before = super::precise_time_ns();
|
||||||
f();
|
f();
|
||||||
|
@ -145,28 +157,33 @@ impl Duration {
|
||||||
|
|
||||||
/// Returns the total number of whole weeks in the duration.
|
/// Returns the total number of whole weeks in the duration.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn num_weeks(&self) -> i64 {
|
pub fn num_weeks(&self) -> i64 {
|
||||||
self.num_days() / 7
|
self.num_days() / 7
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the total number of whole days in the duration.
|
/// Returns the total number of whole days in the duration.
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn num_days(&self) -> i64 {
|
pub fn num_days(&self) -> i64 {
|
||||||
self.num_seconds() / SECS_PER_DAY
|
self.num_seconds() / SECS_PER_DAY
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the total number of whole hours in the duration.
|
/// Returns the total number of whole hours in the duration.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn num_hours(&self) -> i64 {
|
pub fn num_hours(&self) -> i64 {
|
||||||
self.num_seconds() / SECS_PER_HOUR
|
self.num_seconds() / SECS_PER_HOUR
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the total number of whole minutes in the duration.
|
/// Returns the total number of whole minutes in the duration.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn num_minutes(&self) -> i64 {
|
pub fn num_minutes(&self) -> i64 {
|
||||||
self.num_seconds() / SECS_PER_MINUTE
|
self.num_seconds() / SECS_PER_MINUTE
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the total number of whole seconds in the duration.
|
/// Returns the total number of whole seconds in the duration.
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn num_seconds(&self) -> i64 {
|
pub fn num_seconds(&self) -> i64 {
|
||||||
// If secs is negative, nanos should be subtracted from the duration.
|
// If secs is negative, nanos should be subtracted from the duration.
|
||||||
if self.secs < 0 && self.nanos > 0 {
|
if self.secs < 0 && self.nanos > 0 {
|
||||||
|
@ -188,6 +205,7 @@ impl Duration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the total number of whole milliseconds in the duration,
|
/// Returns the total number of whole milliseconds in the duration,
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn num_milliseconds(&self) -> i64 {
|
pub fn num_milliseconds(&self) -> i64 {
|
||||||
// A proper Duration will not overflow, because MIN and MAX are defined
|
// A proper Duration will not overflow, because MIN and MAX are defined
|
||||||
// such that the range is exactly i64 milliseconds.
|
// such that the range is exactly i64 milliseconds.
|
||||||
|
@ -198,6 +216,7 @@ impl Duration {
|
||||||
|
|
||||||
/// Returns the total number of whole microseconds in the duration,
|
/// Returns the total number of whole microseconds in the duration,
|
||||||
/// or `None` on overflow (exceeding 2^63 microseconds in either direction).
|
/// or `None` on overflow (exceeding 2^63 microseconds in either direction).
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn num_microseconds(&self) -> Option<i64> {
|
pub fn num_microseconds(&self) -> Option<i64> {
|
||||||
let secs_part = try_opt!(self.num_seconds().checked_mul(MICROS_PER_SEC));
|
let secs_part = try_opt!(self.num_seconds().checked_mul(MICROS_PER_SEC));
|
||||||
let nanos_part = self.nanos_mod_sec() / NANOS_PER_MICRO;
|
let nanos_part = self.nanos_mod_sec() / NANOS_PER_MICRO;
|
||||||
|
@ -206,6 +225,7 @@ impl Duration {
|
||||||
|
|
||||||
/// Returns the total number of whole nanoseconds in the duration,
|
/// Returns the total number of whole nanoseconds in the duration,
|
||||||
/// or `None` on overflow (exceeding 2^63 nanoseconds in either direction).
|
/// or `None` on overflow (exceeding 2^63 nanoseconds in either direction).
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn num_nanoseconds(&self) -> Option<i64> {
|
pub fn num_nanoseconds(&self) -> Option<i64> {
|
||||||
let secs_part = try_opt!(self.num_seconds().checked_mul(NANOS_PER_SEC as i64));
|
let secs_part = try_opt!(self.num_seconds().checked_mul(NANOS_PER_SEC as i64));
|
||||||
let nanos_part = self.nanos_mod_sec();
|
let nanos_part = self.nanos_mod_sec();
|
||||||
|
@ -213,6 +233,7 @@ impl Duration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add two durations, returning `None` if overflow occured.
|
/// Add two durations, returning `None` if overflow occured.
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn checked_add(&self, rhs: &Duration) -> Option<Duration> {
|
pub fn checked_add(&self, rhs: &Duration) -> Option<Duration> {
|
||||||
let mut secs = try_opt!(self.secs.checked_add(rhs.secs));
|
let mut secs = try_opt!(self.secs.checked_add(rhs.secs));
|
||||||
let mut nanos = self.nanos + rhs.nanos;
|
let mut nanos = self.nanos + rhs.nanos;
|
||||||
|
@ -227,6 +248,7 @@ impl Duration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subtract two durations, returning `None` if overflow occured.
|
/// Subtract two durations, returning `None` if overflow occured.
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn checked_sub(&self, rhs: &Duration) -> Option<Duration> {
|
pub fn checked_sub(&self, rhs: &Duration) -> Option<Duration> {
|
||||||
let mut secs = try_opt!(self.secs.checked_sub(rhs.secs));
|
let mut secs = try_opt!(self.secs.checked_sub(rhs.secs));
|
||||||
let mut nanos = self.nanos - rhs.nanos;
|
let mut nanos = self.nanos - rhs.nanos;
|
||||||
|
@ -242,25 +264,30 @@ impl Duration {
|
||||||
|
|
||||||
/// The minimum possible `Duration`: `i64::MIN` milliseconds.
|
/// The minimum possible `Duration`: `i64::MIN` milliseconds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn min_value() -> Duration { MIN }
|
pub fn min_value() -> Duration { MIN }
|
||||||
|
|
||||||
/// The maximum possible `Duration`: `i64::MAX` milliseconds.
|
/// The maximum possible `Duration`: `i64::MAX` milliseconds.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn max_value() -> Duration { MAX }
|
pub fn max_value() -> Duration { MAX }
|
||||||
|
|
||||||
/// A duration where the stored seconds and nanoseconds are equal to zero.
|
/// A duration where the stored seconds and nanoseconds are equal to zero.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn zero() -> Duration {
|
pub fn zero() -> Duration {
|
||||||
Duration { secs: 0, nanos: 0 }
|
Duration { secs: 0, nanos: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the duration equals `Duration::zero()`.
|
/// Returns `true` if the duration equals `Duration::zero()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
pub fn is_zero(&self) -> bool {
|
pub fn is_zero(&self) -> bool {
|
||||||
self.secs == 0 && self.nanos == 0
|
self.secs == 0 && self.nanos == 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
impl Neg for Duration {
|
impl Neg for Duration {
|
||||||
type Output = Duration;
|
type Output = Duration;
|
||||||
|
|
||||||
|
@ -274,6 +301,7 @@ impl Neg for Duration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
impl Add for Duration {
|
impl Add for Duration {
|
||||||
type Output = Duration;
|
type Output = Duration;
|
||||||
|
|
||||||
|
@ -288,6 +316,7 @@ impl Add for Duration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
impl Sub for Duration {
|
impl Sub for Duration {
|
||||||
type Output = Duration;
|
type Output = Duration;
|
||||||
|
|
||||||
|
@ -302,6 +331,7 @@ impl Sub for Duration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
impl Mul<i32> for Duration {
|
impl Mul<i32> for Duration {
|
||||||
type Output = Duration;
|
type Output = Duration;
|
||||||
|
|
||||||
|
@ -314,6 +344,7 @@ impl Mul<i32> for Duration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "std_misc")]
|
||||||
impl Div<i32> for Duration {
|
impl Div<i32> for Duration {
|
||||||
type Output = Duration;
|
type Output = Duration;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
//! Temporal quantification.
|
//! Temporal quantification.
|
||||||
|
|
||||||
|
#![unstable(feature = "std_misc")]
|
||||||
|
|
||||||
use sys::time::SteadyTime;
|
use sys::time::SteadyTime;
|
||||||
|
|
||||||
pub use self::duration::Duration;
|
pub use self::duration::Duration;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue