diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2021-03-14 13:07:27 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-14 13:07:27 +0900 |
| commit | 6caa350503044420d4fd0cc324b3295a0c19cc70 (patch) | |
| tree | 8e03b0dde18aac7e27fbc7e95e03d49d16d7c437 | |
| parent | acca818928654807ed3bc1ce0e97df118f8716c8 (diff) | |
| parent | 8fd2f0c81f95eeb9440369ac046124d8dbd85a31 (diff) | |
| download | rust-6caa350503044420d4fd0cc324b3295a0c19cc70.tar.gz rust-6caa350503044420d4fd0cc324b3295a0c19cc70.zip | |
Rollup merge of #81465 - joshtriplett:duration-formatting-documentation, r=m-ou-se
Add documentation about formatting `Duration` values Explain why Duration has a Debug impl but not a Display impl, and mention the use of Unicode.
| -rw-r--r-- | library/core/src/time.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/library/core/src/time.rs b/library/core/src/time.rs index b1443bc33d2..8c0848c64aa 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -48,6 +48,17 @@ const MICROS_PER_SEC: u64 = 1_000_000; /// /// let ten_millis = Duration::from_millis(10); /// ``` +/// +/// # Formatting `Duration` values +/// +/// `Duration` intentionally does not have a `Display` impl, as there are a +/// variety of ways to format spans of time for human readability. `Duration` +/// provides a `Debug` impl that shows the full precision of the value. +/// +/// The `Debug` output uses the non-ASCII "µs" suffix for microseconds. If your +/// program output may appear in contexts that cannot rely on full Unicode +/// compatibility, you may wish to format `Duration` objects yourself or use a +/// crate to do so. #[stable(feature = "duration", since = "1.3.0")] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] pub struct Duration { |
