Rust

Rust

By DeepSource

Found manual implementation of `Instant::elapsed`RS-W1045

Anti-pattern
Has Autofix

Subtracting a given Instant, say t, from Instant::now is better expressed with t.elapsed().

Examples

Bad practice

let start_time = Instant::now();
/* ... */
let end_time = Instant::now() - start_time;

Recommended

let start_time = Instant::now();
/* ... */
let end_time = start_time.elapsed();