From b6b5d82e53e2d57559c669a383a74a7b71d93594 Mon Sep 17 00:00:00 2001 From: Mateusz Gienieczko Date: Wed, 2 Oct 2024 03:06:32 +0200 Subject: [PATCH] chore: fix new clippy lints --- crates/rsonpath-lib/src/input/mmap.rs | 8 ++++---- crates/rsonpath-lib/src/result/nodes.rs | 6 +----- crates/rsonpath-syntax/src/parser.rs | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/crates/rsonpath-lib/src/input/mmap.rs b/crates/rsonpath-lib/src/input/mmap.rs index c0a768b4..b35b6918 100644 --- a/crates/rsonpath-lib/src/input/mmap.rs +++ b/crates/rsonpath-lib/src/input/mmap.rs @@ -100,11 +100,11 @@ impl Input for MmapInput { #[inline] fn seek_backward(&self, from: usize, needle: u8) -> Option { - return if from < self.last_block_start { + if from < self.last_block_start { self.mmap.seek_backward(from, needle) } else { self.as_padded_input().seek_backward(from, needle) - }; + } } #[inline] @@ -153,11 +153,11 @@ impl Input for MmapInput { #[inline] fn seek_non_whitespace_backward(&self, from: usize) -> Option<(usize, u8)> { - return if from < self.last_block_start { + if from < self.last_block_start { self.mmap.seek_non_whitespace_backward(from) } else { self.as_padded_input().seek_non_whitespace_backward(from) - }; + } } #[inline] diff --git a/crates/rsonpath-lib/src/result/nodes.rs b/crates/rsonpath-lib/src/result/nodes.rs index 3551886d..8762628e 100644 --- a/crates/rsonpath-lib/src/result/nodes.rs +++ b/crates/rsonpath-lib/src/result/nodes.rs @@ -425,11 +425,7 @@ fn append_block(dest: &mut Vec, src: &[u8], src_start: usize, read_start: us fn append_final_block(dest: &mut Vec, src: &[u8], src_start: usize, read_start: usize, read_end: usize) { debug!("src_start: {src_start}, read_start: {read_start}, read_end: {read_end}"); debug_assert!(read_end >= src_start); - let in_block_start = if read_start > src_start { - read_start - src_start - } else { - 0 - }; + let in_block_start = read_start.saturating_sub(src_start); let in_block_end = read_end - src_start; dest.extend(&src[in_block_start..in_block_end]); diff --git a/crates/rsonpath-syntax/src/parser.rs b/crates/rsonpath-syntax/src/parser.rs index 189fd708..b203c458 100644 --- a/crates/rsonpath-syntax/src/parser.rs +++ b/crates/rsonpath-syntax/src/parser.rs @@ -514,7 +514,7 @@ fn logical_expr<'q>(q: &'q str, ctx: ParseCtx) -> IResult<&'q str, LogicalExpr, return fail(SyntaxErrorKind::NonSingularQueryInComparison, q.len(), query_len, rest); }; if negated { - return fail(SyntaxErrorKind::InvalidNegation, q.len(), 1, rest); + fail(SyntaxErrorKind::InvalidNegation, q.len(), 1, rest) } else { Ok(( rest,