From 35ee9daa8848f54dc9b3cc49c7f71cf7d5927029 Mon Sep 17 00:00:00 2001 From: Josh Rotenberg Date: Tue, 9 Dec 2025 13:03:24 -0800 Subject: [PATCH] fix: resolve clippy collapsible_if warnings Collapse nested if statements into single conditional expressions using let chains, as suggested by clippy. Changes: - parser.rs: Collapse is_peek check with token_queue.front() - variable.rs: Collapse Object/Array pattern matches with inner get() No functional changes - just code style improvements. --- jmespath/src/parser.rs | 5 ++--- jmespath/src/variable.rs | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/jmespath/src/parser.rs b/jmespath/src/parser.rs index 2a542fdd..47d1dae2 100644 --- a/jmespath/src/parser.rs +++ b/jmespath/src/parser.rs @@ -83,11 +83,10 @@ impl<'a> Parser<'a> { let mut actual_pos = self.offset; let mut buff = error_msg.to_string(); buff.push_str(&format!(" -- found {current_token:?}")); - if is_peek { - if let Some(&(p, _)) = self.token_queue.front() { + if is_peek + && let Some(&(p, _)) = self.token_queue.front() { actual_pos = p; } - } JmespathError::new(self.expr, actual_pos, ErrorReason::Parse(buff)) } diff --git a/jmespath/src/variable.rs b/jmespath/src/variable.rs index 40980c8b..bb52350b 100644 --- a/jmespath/src/variable.rs +++ b/jmespath/src/variable.rs @@ -348,22 +348,20 @@ impl Variable { /// Otherwise, returns Null. #[inline] pub fn get_field(&self, key: &str) -> Rcvar { - if let Variable::Object(map) = self { - if let Some(result) = map.get(key) { + if let Variable::Object(map) = self + && let Some(result) = map.get(key) { return result.clone(); } - } Rcvar::new(Variable::Null) } /// If the value is an array, then gets an array value by index. Otherwise returns Null. #[inline] pub fn get_index(&self, index: usize) -> Rcvar { - if let Variable::Array(array) = self { - if let Some(result) = array.get(index) { + if let Variable::Array(array) = self + && let Some(result) = array.get(index) { return result.clone(); } - } Rcvar::new(Variable::Null) }