mem::forget
or mem::drop
on a reference RS-E1010Calling std::mem::forget
(or std::mem::drop
) on a reference will forget (or
drop) the reference itself, which effectively does nothing. The underlying
reference value will remain unaffected.
Consider revisiting this function call. Perhaps you meant to call mem::forget
(or mem::drop
) on the underlying reference value instead.
let x: Vec<u32> = Vec::with_capacity(10);
let y: String = String::new();
std::mem::forget(&x);
std::mem::drop(&y);
let x: Vec<u32> = Vec::with_capacity(10);
let y: String = String::new();
std::mem::forget(x);
std::mem::drop(y);