summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/unchecked_duration_subtraction.fixed
blob: a0e49a8beb1ede7fba56edf5405971721939ccdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// 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();
}