Rust

Rust

Made by DeepSource

Found redundant use of mem::replace RS-W1113

Anti-pattern
Major

The std::mem module provides the take() method to acquire the current value and replace it with the default value of the same type. Prefer using this over mem::replace with T::default().

Bad Practice

let mut text = String::from("foo");
let replaced = std::mem::replace(&mut text, String::default());

Recommended

let mut text = String::from("foo");
let taken = std::mem::take(&mut text);