Feature gate: #![feature(non_panicking_duration_conversion)]
This is a tracking issue for the try_from_{nanos_u128,mins,hours,days,weeks} methods on Duration.
These methods will allow you to convert from a number of minutes, hours, etc, without having to having to check for overflows before calling the method.
Public API
impl Duration {
pub const fn try_from_nanos_u128(nanos: u64) -> Result<Duration, DurationConversionError>;
pub const fn try_from_weeks(weeks: u64) -> Result<Duration, DurationConversionError>;
pub const fn try_from_days(days: u64) -> Result<Duration, DurationConversionError>;
pub const fn try_from_hours(hours: u64) -> Result<Duration, DurationConversionError>;
pub const fn try_from_mins(mins: u64) -> Result<Duration, DurationConversionError>;
}
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
Unresolved Questions
Feature gate:
#![feature(non_panicking_duration_conversion)]This is a tracking issue for the
try_from_{nanos_u128,mins,hours,days,weeks}methods onDuration.These methods will allow you to convert from a number of minutes, hours, etc, without having to having to check for overflows before calling the method.
Public API
Steps / History
(Remember to update the
S-tracking-*label when checking boxes.)Duration::from_{nanos_u128,mins,hours,days,weeks}libs-team#749try_from_{nanos_u128,mins,hours,days,weeks}#153683Unresolved Questions
TryFromFloatSecsErroris still stable, but it's a type alias toDurationConversionErrornow. ButDurationConversionErrorand it'sfmt::Displayimplementation are unstable, sofmt::DisplayforTryFromFloatSecsErrorwas downgraded to unstable. Should this be changed?Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩