From 8203a84c58b0f96986cd12ecab9fdefa31ede592 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Fri, 25 Oct 2024 12:53:05 +0200 Subject: [PATCH] fix some clippy warnings --- crates/node/src/lib.rs | 2 +- crates/node/src/utf16.rs | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/crates/node/src/lib.rs b/crates/node/src/lib.rs index 10d8f99d7..0c8d04939 100644 --- a/crates/node/src/lib.rs +++ b/crates/node/src/lib.rs @@ -128,7 +128,7 @@ impl Scanner { input: ChangedContent, ) -> Vec { let content = input.content.unwrap_or_else(|| { - std::fs::read_to_string(&input.file.unwrap()).expect("Failed to read file") + std::fs::read_to_string(input.file.unwrap()).expect("Failed to read file") }); let input = ChangedContent { diff --git a/crates/node/src/utf16.rs b/crates/node/src/utf16.rs index 7cdebd9fd..a7e7018cb 100644 --- a/crates/node/src/utf16.rs +++ b/crates/node/src/utf16.rs @@ -31,20 +31,18 @@ impl<'a> IndexConverter<'a> { // will only ever be incremented up to the length of the input string. // // This eliminates a "potential" panic that cannot actually happen - let slice = unsafe { - self.input.get_unchecked(self.curr_utf8..) - }; + let slice = unsafe { self.input.get_unchecked(self.curr_utf8..) }; for c in slice.chars() { if self.curr_utf8 >= pos { - break + break; } self.curr_utf8 += c.len_utf8(); self.curr_utf16 += c.len_utf16(); } - return self.curr_utf16 as i64; + self.curr_utf16 as i64 } } @@ -66,19 +64,16 @@ mod test { (4, 4), (5, 5), (6, 6), - // inside the 🔥 (7, 8), (8, 8), (9, 8), (10, 8), - // inside the 🥳 (11, 10), (12, 10), (13, 10), (14, 10), - // world! (15, 11), (16, 12), @@ -87,7 +82,6 @@ mod test { (19, 15), (20, 16), (21, 17), - // Past the end should return the last utf-16 character index (22, 17), (100, 17),