Skip to content

feat(time): add Duration extractors for units larger than second - #165624

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
sorairolake:feature/duration-extractors
Nov 25, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
sorairolake:feature/duration-extractors

Conversation

@sorairolake

@sorairolake sorairolake commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

This pull request adds Duration::as_{weeks,days,hours,mins} methods for units larger than the second.

Based on #120301 and #140881, the features are divided into the duration_extractors feature for Duration::as_{weeks,days} methods and the duration_extractors_lite feature for Duration::as_{hours,mins} methods.

@rustbot rustbot added A-time Area: `std::time` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 8, 2026
@jhpratt

jhpratt commented Nov 8, 2026

Copy link
Copy Markdown
Member

r? jhpratt

As I said in the ACP, personally I'm okay with weeks and days, but there was a difference of opinions there. I'll take a look when the team gets around to discussing the ACP (I expect the minutes and hours to be uncontroversial).

@sorairolake

Copy link
Copy Markdown
Contributor Author

I think Duration::as_{weeks,days} methods should be implemented alongside Duration::as_{hours,mins} methods, provided Duration::from_{weeks,days} constructors and Duration::{WEEK,DAY} associated constants are not removed at this time. If those are to be removed, then the methods themselves should not be implemented.

I think asymmetric states should be avoided.

@jhpratt

jhpratt commented Nov 8, 2026

Copy link
Copy Markdown
Member

Let's keep discussion in the ACP :) I provided a summary of the tradeoffs and opinions for T-libs.

@sorairolake

Copy link
Copy Markdown
Contributor Author

@rustbot label S-waiting-on-ACP

@rustbot rustbot added the S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. label Nov 8, 2026
@sorairolake

Copy link
Copy Markdown
Contributor Author

@rustbot label -S-waiting-on-ACP

@rustbot rustbot removed the S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. label Nov 10, 2026
@sorairolake
sorairolake marked this pull request as ready for review November 10, 2026 23:02
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 10, 2026
@sorairolake

Copy link
Copy Markdown
Contributor Author

I had forgotten about things like #162195, so I took the corresponding actions.

@sorairolake

Copy link
Copy Markdown
Contributor Author

@jhpratt What is lacking for a review?

@jhpratt

jhpratt commented Nov 25, 2026

Copy link
Copy Markdown
Member

You pinging me 😆 I simply forgot about this PR and haven't been active on reviews recently. The team was in favor, so let's land as-is and defer a decision on days/weeks to later (along with the corresponding consts and constructors).

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 076d2b6 has been approved by jhpratt

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 25, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 25, 2026
…ctors, r=jhpratt

feat(time): add `Duration` extractors for units larger than second

- Accepted ACP: rust-lang/libs-team#923
- Tracking issue:
  - rust-lang#165784
  - rust-lang#165786

This pull request adds `Duration::as_{weeks,days,hours,mins}` methods for units larger than the second.

Based on rust-lang#120301 and rust-lang#140881, the features are divided into the `duration_extractors` feature for `Duration::as_{weeks,days}` methods and the `duration_extractors_lite` feature for `Duration::as_{hours,mins}` methods.
rust-bors Bot pushed a commit that referenced this pull request Nov 25, 2026
Rollup of 5 pull requests

Successful merges:

 - #166438 (add test checking that -Ctarget-feature implies cfg(target_feature))
 - #165624 (feat(time): add `Duration` extractors for units larger than second)
 - #166231 (Added regression test for issue #53156 )
 - #166401 (Add explanatory comment and rename alias )
 - #166520 (Fix typo in ConstItemInteriorMutationsDiag struct)
rust-bors Bot pushed a commit that referenced this pull request Nov 25, 2026
Rollup of 9 pull requests

Successful merges:

 - #166438 (add test checking that -Ctarget-feature implies cfg(target_feature))
 - #166536 (Make `issue-96797.rs` link again)
 - #165624 (feat(time): add `Duration` extractors for units larger than second)
 - #166231 (Added regression test for issue #53156 )
 - #166401 (Add explanatory comment and rename alias )
 - #166520 (Fix typo in ConstItemInteriorMutationsDiag struct)
 - #166540 (Return `Err` from `send_process_group_signal` if leader has been awaited)
 - #166544 (rustc-dev-guide subtree update)
 - #166545 (Run more autodiff tests in CI)
@rust-bors
rust-bors Bot merged commit 8e52515 into rust-lang:main Nov 25, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 25, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 25, 2026
Rollup merge of #165624 - sorairolake:feature/duration-extractors, r=jhpratt

feat(time): add `Duration` extractors for units larger than second

- Accepted ACP: rust-lang/libs-team#923
- Tracking issue:
  - #165784
  - #165786

This pull request adds `Duration::as_{weeks,days,hours,mins}` methods for units larger than the second.

Based on #120301 and #140881, the features are divided into the `duration_extractors` feature for `Duration::as_{weeks,days}` methods and the `duration_extractors_lite` feature for `Duration::as_{hours,mins}` methods.
@tgross35

Copy link
Copy Markdown
Member

@sorairolake in the future could you please make sure your git history is free from back-and-forth changes? I.e. squash smaller changes that don't have a reason to be split up.

Thanks!

@sorairolake
sorairolake deleted the feature/duration-extractors branch November 25, 2026 16:02
@jhpratt

jhpratt commented Nov 25, 2026

Copy link
Copy Markdown
Member

Whoops, that's also on me as a reviewer

@sorairolake

Copy link
Copy Markdown
Contributor Author

@tgross35 I'm sorry, since the number of commits was small, I thought it might not be necessary to squash them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-time Area: `std::time` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants