From bf45b8b6b46e6a14515b9d56b52631f0fbfd76c5 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Thu, 11 Aug 2022 16:54:18 +0200 Subject: [PATCH] Silence a bad Clippy suggestion Clippy suggests !('\u{fe00}'..='\u{fe0f}').contains(&ch) instead of (ch < '\u{fe00}' || ch > '\u{fe0f}') I disagree, because: * It adds more line noise (negation, &ch instead of ch). * It's hard to read (no space around character literals, which are already cluttered by the \ and {}, it becomes a line full of sigils.) * It uses the arcane ..= syntax that is relatively recent and very uncommon. Readers are not likely to know what it means. * It calls a method on a range, which is also somewhat arcane. It makes sense, but I think it is less obvious to a reader who may not know Rust as well, as plain comparisons that exist in any language. * "Inclusive range does not contain" does not feel obviously simpler to me than "outside of these bounds". For integer literals it might make sense, but in this case the suggestion looks like code golfing to me. It is also longer. --- cli/maintainer/src/maintenance.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/maintainer/src/maintenance.rs b/cli/maintainer/src/maintenance.rs index dd5660be2..523c00b81 100644 --- a/cli/maintainer/src/maintenance.rs +++ b/cli/maintainer/src/maintenance.rs @@ -420,6 +420,8 @@ fn sanitize_validator_name(name: &str) -> String { // adds no information, strip it here to leave more space for graphs in // dashboards, and not waste so much space on the redundant part of the name. match name.strip_prefix("Lido / ") { + // Negated range.contains syntax only makes things more cryptic below. + #[allow(clippy::manual_range_contains)] // I don't want distracting emojis in my Grafana dashboards. Some(suffix) => suffix .chars()