diff options
| author | Claudio Bley <claudio.bley@gmail.com> | 2018-05-31 22:05:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-31 22:05:36 +0200 |
| commit | 95e2bf253d864c5e14ad000ffa2040ce85916056 (patch) | |
| tree | 3885e57ef058bda332d83d516fe2cfef4d33ebed /src/libstd/sys/unix/time.rs | |
| parent | 5342d40c1f49ef82ebff4c30fdad9f3b6fd339c1 (diff) | |
| download | rust-95e2bf253d864c5e14ad000ffa2040ce85916056.tar.gz rust-95e2bf253d864c5e14ad000ffa2040ce85916056.zip | |
Fix confusing error message for sub_instant
When subtracting an Instant from another, the function will panick when `RHS > self`, but the error message confusingly displays a different error:
```rust
let i = Instant::now();
let other = Instant::now();
if other > i {
println!("{:?}", i - other);
}
```
This results in a panic:
```
thread 'test_instant' panicked at 'other was less than the current instant', libstd/sys/unix/time.rs:292:17
```Diffstat (limited to 'src/libstd/sys/unix/time.rs')
| -rw-r--r-- | src/libstd/sys/unix/time.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index 83127935909..f7459cb55d5 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -289,7 +289,7 @@ mod inner { pub fn sub_instant(&self, other: &Instant) -> Duration { self.t.sub_timespec(&other.t).unwrap_or_else(|_| { - panic!("other was less than the current instant") + panic!("other was greater than the current instant") }) } |
