From 9a0edd0ce56b525de90c9982a171b9b59f72957b Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Fri, 27 Jun 2025 09:31:24 +0200 Subject: [PATCH] rust/dns: fix clippy char_indices_as_byte_indices error: indexing into a string with a character position where a byte index is expected --> src/dns/detect.rs:45:39 | 45 | let code: u8 = opcode[i..].parse().map_err(|_| ())?; | ^ | = note: a character can take up more than one byte, so they are not interchangeable note: position comes from the enumerate iterator --> src/dns/detect.rs:36:10 | 36 | for (i, c) in opcode.chars().enumerate() { | ^ ^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#char_indices_as_byte_indices = note: `#[deny(clippy::char_indices_as_byte_indices)]` on by default help: consider using `.char_indices()` instead | 36 - for (i, c) in opcode.chars().enumerate() { 36 + for (i, c) in opcode.char_indices() { --- rust/src/dns/detect.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/src/dns/detect.rs b/rust/src/dns/detect.rs index 268a409eac..0ee3891983 100644 --- a/rust/src/dns/detect.rs +++ b/rust/src/dns/detect.rs @@ -33,7 +33,7 @@ pub struct DetectDnsOpcode { /// the details of the error. fn parse_opcode(opcode: &str) -> Result { let mut negated = false; - for (i, c) in opcode.chars().enumerate() { + for (i, c) in opcode.char_indices() { match c { ' ' | '\t' => { continue; -- 2.47.2