RS.CLIPPY.OPTION_AS_REF_DEREF
Using `as_ref().map(Deref::deref)`, which is more succinctly expressed as `as_deref()`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: option_as_ref_deref. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of _.as_ref().map(Deref::deref) or its aliases (such as String::as_str).
Why is this bad?
Readability, this can be written more concisely as
_.as_deref().
Example
opt.as_ref().map(String::as_str)
Can be written as
opt.as_deref()
Configuration
-
msrv: The minimum rust version that the project supports. Defaults to therust-versionfield inCargo.toml(default:
current version)