Skip to content

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

Closed
@kennytm

Description

@kennytm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions