]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
rust(lint): map the error instead of using or_else
authorJason Ish <jason.ish@oisf.net>
Fri, 20 Aug 2021 17:38:31 +0000 (11:38 -0600)
committerVictor Julien <victor@inliniac.net>
Mon, 23 Aug 2021 08:03:12 +0000 (10:03 +0200)
This is the preffered style and easier to understand the meaning
of the code.

rust/src/dns/detect.rs

index 326e9c38a714dc2fcfde073438c4c608850fa91f..b389d2c57f11db43dd7baa6a21570552f0342068 100644 (file)
@@ -42,7 +42,7 @@ fn parse_opcode(opcode: &str) -> Result<DetectDnsOpcode, ()> {
                 negated = true;
             }
             _ => {
-                let code: u8 = (&opcode[i..]).parse().or_else(|_| Err(()))?;
+                let code: u8 = (&opcode[i..]).parse().map_err(|_| ())?;
                 return Ok(DetectDnsOpcode {
                     negate: negated,
                     opcode: code,