RS.CLIPPY.USELESS_ASREF
Using `as_ref` where the types before and after the call are the same
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: useless_asref. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of .as_ref() or .as_mut() where the
types before and after the call are the same.
Why is this bad?
The call is unnecessary.
Example
let x: &[i32] = &[1, 2, 3, 4, 5];
do_stuff(x.as_ref());
The correct use would be:
let x: &[i32] = &[1, 2, 3, 4, 5];
do_stuff(x);