RS.CLIPPY.MANUAL_IGNORE_CASE_CMP
Manual case-insensitive ASCII comparison
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: manual_ignore_case_cmp. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for manual case-insensitive ASCII comparison.
Why is this bad?
The eq_ignore_ascii_case method is faster because it does not allocate
memory for the new strings, and it is more readable.
Example
fn compare(a: &str, b: &str) -> bool {
a.to_ascii_lowercase() == b.to_ascii_lowercase() || a.to_ascii_lowercase() == "abc"
}
Use instead:
fn compare(a: &str, b: &str) -> bool {
a.eq_ignore_ascii_case(b) || a.eq_ignore_ascii_case("abc")
}