Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,15 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_constructors)]
/// #![feature(duration_constructors_lite)]
/// use std::time::Duration;
///
/// let duration = Duration::from_hours(6);
///
/// assert_eq!(6 * 60 * 60, duration.as_secs());
/// assert_eq!(0, duration.subsec_nanos());
/// ```
#[unstable(feature = "duration_constructors", issue = "120301")]
#[unstable(feature = "duration_constructors_lite", issue = "140881")]
#[must_use]
#[inline]
pub const fn from_hours(hours: u64) -> Duration {
Expand All @@ -401,15 +401,15 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_constructors)]
/// #![feature(duration_constructors_lite)]
/// use std::time::Duration;
///
/// let duration = Duration::from_mins(10);
///
/// assert_eq!(10 * 60, duration.as_secs());
/// assert_eq!(0, duration.subsec_nanos());
/// ```
#[unstable(feature = "duration_constructors", issue = "120301")]
#[unstable(feature = "duration_constructors_lite", issue = "140881")]
#[must_use]
#[inline]
pub const fn from_mins(mins: u64) -> Duration {
Expand Down
1 change: 1 addition & 0 deletions library/coretests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#![feature(dec2flt)]
#![feature(duration_constants)]
#![feature(duration_constructors)]
#![feature(duration_constructors_lite)]
#![feature(error_generic_member_access)]
#![feature(exact_size_is_empty)]
#![feature(extend_one)]
Expand Down
11 changes: 10 additions & 1 deletion library/coretests/tests/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,25 @@ fn from_weeks_overflow() {
}

#[test]
fn constructors() {
fn constructor_weeks() {
assert_eq!(Duration::from_weeks(1), Duration::from_secs(7 * 24 * 60 * 60));
assert_eq!(Duration::from_weeks(0), Duration::ZERO);
}

#[test]
fn constructor_days() {
assert_eq!(Duration::from_days(1), Duration::from_secs(86_400));
assert_eq!(Duration::from_days(0), Duration::ZERO);
}

#[test]
fn constructor_hours() {
assert_eq!(Duration::from_hours(1), Duration::from_secs(3_600));
assert_eq!(Duration::from_hours(0), Duration::ZERO);
}

#[test]
fn constructor_minutes() {
assert_eq!(Duration::from_mins(1), Duration::from_secs(60));
assert_eq!(Duration::from_mins(0), Duration::ZERO);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `duration_constructors_lite`

The tracking issue for this feature is: [#140881]

[#140881]: https://github.com/rust-lang/rust/issues/140881

------------------------

Add the methods `from_mins`, `from_hours` to `Duration`.

For `from_days` and `from_weeks` see [`duration_constructors`](https://github.com/rust-lang/rust/issues/120301).
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ The tracking issue for this feature is: [#120301]

------------------------

Add the methods `from_mins`, `from_hours` and `from_days` to `Duration`.
Add the methods `from_days` and `from_weeks` to `Duration`.
For `from_mins` and `from_hours` see [duration-constructors-lite.md](./duration-constructors-lite.md)
Original file line number Diff line number Diff line change
Expand Up @@ -5789,7 +5789,7 @@ The tracking issue for this feature is: [#120301]

------------------------

Add the methods `from_mins`, `from_hours` and `from_days` to `Duration`.
Add the methods `from_days` and `from_weeks` to `Duration`.
"##,
default_severity: Severity::Allow,
warn_since: None,
Expand Down
Loading