From: Jason Ish Date: Mon, 3 Oct 2022 21:25:50 +0000 (-0600) Subject: rust: fix clippy lint for redundant_closure X-Git-Tag: suricata-7.0.0-beta1~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9597f3d0c93e225fddda839a2d8a5174d6591a4;p=thirdparty%2Fsuricata.git rust: fix clippy lint for redundant_closure Removes a closure where the function can be directly provided. --- diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index bea80bb02c..3c493a44da 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -678,6 +678,6 @@ pub trait AppLayerFrameType { /// Converts a variant ID to an FFI safe name. extern "C" fn ffi_name_from_id(id: u8) -> *const std::os::raw::c_char where Self: Sized { - Self::from_u8(id).map(|s| s.to_cstring()).unwrap_or_else(|| std::ptr::null()) + Self::from_u8(id).map(|s| s.to_cstring()).unwrap_or_else(std::ptr::null) } } diff --git a/rust/src/detect/iprep.rs b/rust/src/detect/iprep.rs index d05040f221..1e8c0e428e 100644 --- a/rust/src/detect/iprep.rs +++ b/rust/src/detect/iprep.rs @@ -76,7 +76,7 @@ extern "C" { pub fn detect_parse_iprep(i: &str) -> IResult<&str, DetectIPRepData> { let (i, _) = opt(is_a(" "))(i)?; - let (i, cmd) = map_res(alpha0, |s: &str| DetectIPRepDataCmd::from_str(s))(i)?; + let (i, cmd) = map_res(alpha0, DetectIPRepDataCmd::from_str)(i)?; let (i, _) = opt(is_a(" "))(i)?; let (i, _) = char(',')(i)?; let (i, _) = opt(is_a(" "))(i)?; diff --git a/rust/src/detect/stream_size.rs b/rust/src/detect/stream_size.rs index 5902e88e51..c7373eb714 100644 --- a/rust/src/detect/stream_size.rs +++ b/rust/src/detect/stream_size.rs @@ -59,7 +59,7 @@ pub struct DetectStreamSizeData { pub fn detect_parse_stream_size(i: &str) -> IResult<&str, DetectStreamSizeData> { let (i, _) = opt(is_a(" "))(i)?; - let (i, flags) = map_res(alpha0, |s: &str| DetectStreamSizeDataFlags::from_str(s))(i)?; + let (i, flags) = map_res(alpha0, DetectStreamSizeDataFlags::from_str)(i)?; let (i, _) = opt(is_a(" "))(i)?; let (i, _) = char(',')(i)?; let (i, _) = opt(is_a(" "))(i)?; diff --git a/rust/src/ike/parser.rs b/rust/src/ike/parser.rs index 732146ea35..1cdd07691e 100644 --- a/rust/src/ike/parser.rs +++ b/rust/src/ike/parser.rs @@ -471,7 +471,7 @@ pub fn parse_sa_attribute(i: &[u8]) -> IResult<&[u8], Vec> { }, hex_value: match format.0 { 0 => variable_attribute_value - .map(|_variable_attribute_value| to_hex(_variable_attribute_value)), + .map(to_hex), _ => None, }, };