RS.CLIPPY.EXPLICIT_DEREF_METHODS
Explicit use of deref or deref_mut method while not in a method chain.
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: explicit_deref_methods. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for explicit deref() or deref_mut() method calls.
Why is this bad?
Dereferencing by &*x or &mut *x is clearer and more concise,
when not part of a method chain.
Example
use std::ops::Deref;
let a: &mut String = &mut String::from("foo");
let b: &str = a.deref();
Use instead:
let a: &mut String = &mut String::from("foo");
let b = &*a;
This lint excludes all of:
let _ = d.unwrap().deref();
let _ = Foo::deref(&foo);
let _ = <Foo as Deref>::deref(&foo);