Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associated constants for new duration constructors #127700

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

edwardwc
Copy link

Add associated constants to the unstable Duration constructors. The tracking issue for these constructors is #120301.

This change aims to make interacting with time more clean and intuitive by providing predefined duration constants.

For example, to use a static for your sleep intervals:

static SLEEP_INTERVAL: Duration = Duration::HOUR;

...

sleep(SLEEP_INTERVAL)

Or with use of a lazy_static

lazy_static! {
    static ref SLEEP_INTERVAL: Duration = 5 * Duration::MINUTE;
}

...

sleep(*SLEEP_INTERVAL)

Or, to use it plainly

sleep(Duration::WEEK)

@rustbot
Copy link
Collaborator

rustbot commented Jul 13, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @scottmcm (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 13, 2024
@scottmcm
Copy link
Member

Do you have an ACP for these? They're not obvious enough to me that I'd be willing to approve them, even for nightly, without libs-api weighing in.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2024
Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding these makes sense to me -- not sure if they should be part of the same feature?

@edwardwc
Copy link
Author

@djc up to you. My thinking is it could be reasonable to bundle these associated constants with their required constructor counterparts as one feature.

@djc
Copy link
Contributor

djc commented Jul 21, 2024

I don't think it's up to me -- I'm not a libs reviewer.

@Dylan-DPC Dylan-DPC added the needs-acp This change is blocked on the author creating an ACP. label Aug 21, 2024
@Dylan-DPC
Copy link
Member

@edwardwc this needs an ACP to be written to proceed. Once you have submitted the ACP, you can mention it here (preferably in the pr description)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-acp This change is blocked on the author creating an ACP. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants