Skip to content

Suggestion: Replace d.subsec_nanos() / 1_000_000 with d.subsec_millis() #2543

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

Closed
kennytm opened this issue Mar 17, 2018 · 0 comments
Closed
Labels
A-lint Area: New lints

Comments

@kennytm
Copy link
Member

kennytm commented Mar 17, 2018

rust-lang/rust#46507 may soon be stabilized. Code that computes the milliseconds/microseconds-part of a duration could use the .subsec_millis()/.subsec_micros() methods directly instead of going through a computation with lots of zeros. Clippy should add a lint for the following patterns:

Old New
dur.subsec_nanos() / 1_000_000 dur.subsec_millis()
dur.subsec_nanos() / 1_000 dur.subsec_micros()

This mainly helps modernizing existing code.

@kennytm kennytm added the A-lint Area: New lints label Mar 17, 2018
@ghost ghost mentioned this issue Jun 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

1 participant