rust/src/libcore
Lukas Kalbertodt 9eeb13fdd1
Improve Debug impl of core::time::Duration
Prior to this, Duration simply derived Debug. Since Duration doesn't
implement `Display`, the only way to inspect its value is to use
`Debug`. Unfortunately, the derived `Debug` impl is far from optimal
for humans. In many cases, Durations are used for some quick'n'dirty
benchmarking (or in general: measuring the time of some code). Correctly
understanding the output of Duration's Debug impl is not easy (e.g.
is "{ secs: 0, nanos: 968360102 }" or "{ secs: 0, nanos 98507324 }"
shorter?).

This commit replaces the derived impl with a manual one. It prints
the duration as seconds (i.e. "3.1803s") if the duration is longer than
a second, otherwise it prints it in either ms, µs or ns (depending on
the duration's length). This already helps readability a lot and it
never omits information that is stored.

This `Debug` impl does *not* respect the following formatting parameters:

- fill/align/padding: difficult to implement, probably not worth it
- alternate # flag: not clear what this should do
2018-05-06 13:46:20 +02:00
..
benches Move deny(warnings) into rustbuild 2018-04-08 16:59:14 -06:00
char Rollup merge of #49970 - SimonSapin:deprecate, r=sfackler 2018-04-24 11:57:05 +08:00
fmt Suggest more helpful formatting string 2018-05-05 11:50:02 +01:00
hash Fix a few more unstables that I missed 2018-03-26 08:37:56 -05:00
iter Fix some broken links in docs. 2018-04-29 10:15:40 -07:00
num core: Minor cleanup 2018-04-24 03:32:40 +09:00
ops new() should be const; start()/end() after iteration is unspecified. 2018-05-01 01:45:18 +08:00
prelude Replace StrExt with inherent str methods in libcore 2018-04-21 09:47:37 +02:00
slice Move the tests in src/libcore/slice/memchr.rs as well. 2018-05-06 02:34:07 +08:00
str Auto merge of #49896 - SimonSapin:inherent, r=alexcrichton 2018-04-22 00:01:29 +00:00
sync Auto merge of #48553 - seanmonstar:atomic-debug, r=alexcrichton 2018-04-19 23:08:16 +00:00
tests Improve Debug impl of core::time::Duration 2018-05-06 13:46:20 +02:00
unicode Fix a warning in libcore on 16bit targets. 2018-05-01 17:48:31 +03:00
alloc.rs Remove Alloc::oom 2018-04-22 10:08:49 -07:00
any.rs stage0 cfg cleanup 2018-02-20 08:52:33 -07:00
array.rs Revert "Stabilize the TryFrom and TryInto traits" 2018-04-20 18:10:00 +02:00
ascii.rs Correct a few stability attributes 2018-04-05 15:39:29 +01:00
borrow.rs Fix formatting. 2018-03-18 13:05:00 +01:00
Cargo.toml Update Cargo submodule 2018-03-11 10:59:28 -07:00
cell.rs Assign the tracking issue 2018-04-23 20:34:49 +02:00
clone.rs Revert stabilization of feature(never_type). 2018-04-20 18:09:28 +02:00
cmp.rs Add more doc aliases 2018-04-26 12:56:10 +02:00
convert.rs Revert "Stabilize the TryFrom and TryInto traits" 2018-04-20 18:10:00 +02:00
default.rs Fix "Quasi-quoting is inefficient" warning in incremental rustbuild. 2017-07-18 01:49:40 +08:00
hint.rs Stabilize core::hint::unreachable_unchecked. 2018-04-16 18:29:40 +08:00
internal_macros.rs Make the unstable StrExt and SliceExt traits private to libcore in not(stage0) 2018-04-21 09:47:38 +02:00
intrinsics.rs Stabilize core::hint::unreachable_unchecked. 2018-04-16 18:29:40 +08:00
iter_private.rs Various fixes to wording consistency in the docs 2017-03-22 17:19:52 +01:00
lib.rs Added some simple documentation. 2018-05-06 03:29:19 +08:00
macros.rs update concat_idents doc stubs 2018-05-03 06:49:30 -04:00
marker.rs Fix some broken links in docs. 2018-04-29 10:15:40 -07:00
mem.rs Stabilize core::hint::unreachable_unchecked. 2018-04-16 18:29:40 +08:00
nonzero.rs num::NonZero* types now have their own tracking issue: #49137 2018-03-18 16:58:38 +01:00
option.rs Remove uses of option_filter feature 2018-04-05 00:02:33 -06:00
panic.rs std: Avoid allocating panic message unless needed 2018-04-13 07:04:24 -07:00
panicking.rs Bump the bootstrap compiler to 1.26.0 beta 2018-04-05 07:13:45 -07:00
ptr.rs Rollup merge of #50233 - mark-i-m:const_vec, r=kennytm 2018-05-01 01:18:36 +08:00
raw.rs Fix up various links 2017-03-20 10:10:16 -04:00
result.rs core: Update stability attributes for FusedIterator 2018-03-03 14:23:05 +01:00
time.rs Improve Debug impl of core::time::Duration 2018-05-06 13:46:20 +02:00
tuple.rs Update bootstrap compiler 2017-08-31 06:58:58 -07:00
unit.rs impl FromIterator<()> for () 2017-10-18 23:12:37 -07:00