Rust

Rust

Made by DeepSource

Found manual implementation of Instant::elapsed RS-W1045

Anti-pattern
Minor
Autofix

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

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();