소스 검색

Pad output of `Display` on `Instant`

Zero-pad the milliseconds part of a displayed `Instant` to include
three leading zeros.
Closes: #297
Approved by: whitequark
David Wood 5 년 전
부모
커밋
0f6144331b
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/time.rs

+ 1 - 1
src/time.rs

@@ -168,7 +168,7 @@ impl Duration {
 
 impl fmt::Display for Duration {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}.{}s", self.secs(), self.millis())
+        write!(f, "{}.{:03}s", self.secs(), self.millis())
     }
 }