Tracking Issue for `try_from_{nanos_u128,mins,hours,days,weeks}` methods on `Duration`
Open
@Zorbatron is already working on this.
Since Mar 10, 2026.
C-tracking-issue
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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.)
- ACP: rust-lang/libs-team#749
- Implementation: #153683
- Final comment period (FCP)^1
- Stabilization PR
Unresolved 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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.