mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 09:27:25 +00:00
17 lines
438 B
Rust
17 lines
438 B
Rust
//@run-rustfix
|
|
#![warn(clippy::unchecked_duration_subtraction)]
|
|
|
|
use std::time::{Duration, Instant};
|
|
|
|
fn main() {
|
|
let _first = Instant::now();
|
|
let second = Duration::from_secs(3);
|
|
|
|
let _ = _first.checked_sub(second).unwrap();
|
|
|
|
let _ = Instant::now().checked_sub(Duration::from_secs(5)).unwrap();
|
|
|
|
let _ = _first.checked_sub(Duration::from_secs(5)).unwrap();
|
|
|
|
let _ = Instant::now().checked_sub(second).unwrap();
|
|
}
|