From 5cf80d8cefc860a300827038a2c588cd5a4c033a Mon Sep 17 00:00:00 2001 From: Ihor Andrianov Date: Thu, 30 Jan 2025 02:40:35 +0200 Subject: [PATCH] cargo clippy --- core/json/json_operations.rs | 2 +- core/json/mod.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/json/json_operations.rs b/core/json/json_operations.rs index 70f7af689..f00c4d20e 100644 --- a/core/json/json_operations.rs +++ b/core/json/json_operations.rs @@ -151,7 +151,7 @@ impl JsonPatcher { } pub fn json_remove(args: &[OwnedValue]) -> crate::Result { - if args.len() == 0 { + if args.is_empty() { return Ok(OwnedValue::Null); } if args.len() == 1 { diff --git a/core/json/mod.rs b/core/json/mod.rs index b4665baf5..da3946fc5 100644 --- a/core/json/mod.rs +++ b/core/json/mod.rs @@ -409,11 +409,11 @@ enum Target<'a> { Value(&'a mut Val), } -fn mutate_json_by_path(json: &mut Val, path: JsonPath, mut closure: F) -> Option +fn mutate_json_by_path(json: &mut Val, path: JsonPath, closure: F) -> Option where F: FnMut(Target) -> R, { - find_target(json, &path).map(|target| closure(target)) + find_target(json, &path).map(closure) } fn find_target<'a>(json: &'a mut Val, path: &JsonPath) -> Option> { @@ -425,7 +425,7 @@ fn find_target<'a>(json: &'a mut Val, path: &JsonPath) -> Option> { PathElement::ArrayLocator(index) => match current { Val::Array(arr) => { if let Some(index) = match index { - i if *i < 0 => arr.len().checked_sub(i.abs() as usize), + i if *i < 0 => arr.len().checked_sub(i.unsigned_abs() as usize), i => ((*i as usize) < arr.len()).then_some(*i as usize), } { if is_last { @@ -459,7 +459,7 @@ fn find_target<'a>(json: &'a mut Val, path: &JsonPath) -> Option> { }, } } - return Some(Target::Value(current)); + Some(Target::Value(current)) } pub fn json_error_position(json: &OwnedValue) -> crate::Result {