diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-02-10 02:19:31 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-10 02:19:31 +0000 |
| commit | 023b0d5b2270f31aa69e54aa3d43416e16c33966 (patch) | |
| tree | 134e12f460be9660e7be3fb4dcf92a9a938d4de2 /examples/std/src/bin | |
| parent | e1a0df7d46419962b92c36d8efd8c4840eef7349 (diff) | |
| parent | bd7b3bd455fc5946a3944bd931acfdf255929cb6 (diff) | |
Merge #1209
1209: Time: Add from_hz function for Duration. r=Dirbaio a=CBJamo
I found myself doing things like this
```rust
let rate_us = 1_000_000 / rate_hz;
let mut ticker = Ticker::every(Duration::from_micros(rate_us));
```
Several times, and figured it was worth adding a little convenience function to handle that. This also makes the calculation const, which is a nice little upside. The compiler might have been doing that already, but this makes sure.
Speaking of const, would it be better to give hz as a float? Obviously we'd want to avoid that at runtime since many targets don't have a fpu, but if it's at compile time that doesn't matter and a float may be more ergonomic.
Co-authored-by: Caleb Jamison <[email protected]>
Diffstat (limited to 'examples/std/src/bin')
0 files changed, 0 insertions, 0 deletions
