Repository navigation
Closed
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRStatus: This is ready to stabilize; it may need a stabilization report and a PRT-libs-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Milestone
Description
Feature gate: #![feature(duration_from_nanos_u128)]
This is a tracking issue for Duration::from_nanos_u128. See the ACP at rust-lang/libs-team#567.
Public API
// std::time
impl Duration {
/// Creates a new Duration from the specified number of nanoseconds.
///
/// # Panics
///
/// Panics if the given number of nanoseconds overflows the Duration size.
pub const fn from_nanos_u128(nanos: u128) -> Duration;
}Steps / History
- Implementation: Add Duration::from_nanos_u128 #145969
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Is this the best name we can come up with?
- Should we instead try to generalize
from_nanoswith a sealed trait? That would block this on const traits.
Footnotes
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRStatus: This is ready to stabilize; it may need a stabilization report and a PRT-libs-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Activity
Add unstable attribute
Add unstable attribute
Add unstable attribute
Add from_nanos_u128 to Duration for handling large time spans
clarfonthey commentedon May 31, 2025
It would be a bit unprecedented and require const traits, but it feels like the most ideal way to do this would be to use a sealed trait to allow calling this method with both
u128andu64. That way, backwards compatibility isn't broken, but we don't need to settle for a weird, unintuitive combination of methods.I know that this sort of change can break inference, but I know such breakages are allowed as "non-breaking" changes and there probably wouldn't be a massive impact here.
(note: const traits are only required since the method is already stably const)
Add from_nanos_u128 to Duration for handling large time spans
tgross35 commentedon Aug 27, 2025
Labeling help wanted: there is a PR at #139243, but @omanirudh requested that somebody else take over #139243 (comment). It should be pretty straightforward to get this over the line: for anybody interested, start with that PR as a base and address the review comments that haven't yet been resolved.
(@omanirudh feel free to correct this if you are still interested in continuing)
Rollup merge of rust-lang#145969 - actuallylost:duration-from-nanos-1…
Unrolled build for #145969
Rollup merge of rust-lang#145969 - actuallylost:duration-from-nanos-1…
20 remaining items
Rollup merge of rust-lang#148587 - RalfJung:duration_from_nanos_u128,…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…
Auto merge of rust-lang#148587 - RalfJung:duration_from_nanos_u128, r…
Auto merge of rust-lang#148587 - RalfJung:duration_from_nanos_u128, r…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…
Auto merge of #148587 - RalfJung:duration_from_nanos_u128, r=Mark-Sim…