RS.CLIPPY.NEEDLESS_BORROWED_REFERENCE
Destructuring a reference and borrowing the inner value
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: needless_borrowed_reference. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for bindings that needlessly destructure a reference and borrow the inner
value with &ref.
Why is this bad?
This pattern has no effect in almost all cases.
Example
let mut v = Vec::<String>::new();
v.iter_mut().filter(|&ref a| a.is_empty());
if let &[ref first, ref second] = v.as_slice() {}
Use instead:
let mut v = Vec::<String>::new();
v.iter_mut().filter(|a| a.is_empty());
if let [first, second] = v.as_slice() {}