Consider adding a from_micros for std::time::Duration
· Issue #44400 · rust-lang/rust (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
During the write of an embedded library I needed to make a pause of 10 microseconds. Looking over the Nightly std::time::Duration documentation page I understood that I had to use the following construction:
// Wait 10 microseconds thread::sleep(Duration::new(0, 10_000));
The sad part is that this is less clear to me than Duration::from_micros(10)
. Currently the from_millis
and from_secs
functions are implemented but not from_micros
which could help write cleaner code IMO.
The fix seems pretty easy, maybe if you judge this useful I can try to write my first pull request to the Rust project!