RS.CLIPPY.CMP_OWNED
Creating owned instances for comparing with others, e.g., `x == \"foo\".to_string()`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: cmp_owned. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for conversions to owned values just for the sake of a comparison.
Why is this bad?
The comparison can operate on a reference, so creating an owned value effectively throws it away directly afterwards, which is needlessly consuming code and heap space.
Example
if x.to_owned() == y {}
Use instead:
if x == y {}