From 4fa28b3de221f643f3515b799e01c775b1e31515 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 1 Jan 2024 23:50:14 +0100 Subject: [PATCH] chore: fix clippy lints for rope2, sum_tree, text2 and util --- crates/rope2/src/rope2.rs | 2 +- crates/sum_tree/src/tree_map.rs | 6 ++---- crates/text2/src/locator.rs | 4 ++-- crates/text2/src/subscription.rs | 2 +- crates/text2/src/text2.rs | 2 +- crates/util/src/paths.rs | 6 +++--- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/crates/rope2/src/rope2.rs b/crates/rope2/src/rope2.rs index 4cea1d4759..adfcd19a6c 100644 --- a/crates/rope2/src/rope2.rs +++ b/crates/rope2/src/rope2.rs @@ -906,7 +906,7 @@ impl Chunk { fn clip_offset_utf16(&self, target: OffsetUtf16, bias: Bias) -> OffsetUtf16 { let mut code_units = self.0.encode_utf16(); - let mut offset = code_units.by_ref().take(target.0 as usize).count(); + let mut offset = code_units.by_ref().take(target.0).count(); if char::decode_utf16(code_units).next().transpose().is_err() { match bias { Bias::Left => offset -= 1, diff --git a/crates/sum_tree/src/tree_map.rs b/crates/sum_tree/src/tree_map.rs index edb9010e50..f39e3ed19a 100644 --- a/crates/sum_tree/src/tree_map.rs +++ b/crates/sum_tree/src/tree_map.rs @@ -40,7 +40,7 @@ impl TreeMap { self.0.is_empty() } - pub fn get<'a>(&self, key: &'a K) -> Option<&V> { + pub fn get(&self, key: &K) -> Option<&V> { let mut cursor = self.0.cursor::>(); cursor.seek(&MapKeyRef(Some(key)), Bias::Left, &()); if let Some(item) = cursor.item() { @@ -98,9 +98,7 @@ impl TreeMap { let from_key = MapKeyRef(Some(from)); cursor.seek(&from_key, Bias::Left, &()); - cursor - .into_iter() - .map(|map_entry| (&map_entry.key, &map_entry.value)) + cursor.map(|map_entry| (&map_entry.key, &map_entry.value)) } pub fn update(&mut self, key: &K, f: F) -> Option diff --git a/crates/text2/src/locator.rs b/crates/text2/src/locator.rs index 07b73ace05..0fb2fa5d16 100644 --- a/crates/text2/src/locator.rs +++ b/crates/text2/src/locator.rs @@ -20,11 +20,11 @@ impl Locator { } pub fn min_ref() -> &'static Self { - &*MIN + &MIN } pub fn max_ref() -> &'static Self { - &*MAX + &MAX } pub fn assign(&mut self, other: &Self) { diff --git a/crates/text2/src/subscription.rs b/crates/text2/src/subscription.rs index b636dfcc92..878e8a2cfe 100644 --- a/crates/text2/src/subscription.rs +++ b/crates/text2/src/subscription.rs @@ -18,7 +18,7 @@ impl Topic { } pub fn publish(&self, edits: impl Clone + IntoIterator>) { - publish(&mut *self.0.lock(), edits); + publish(&mut self.0.lock(), edits); } pub fn publish_mut(&mut self, edits: impl Clone + IntoIterator>) { diff --git a/crates/text2/src/text2.rs b/crates/text2/src/text2.rs index c05ea1109c..f0931a7672 100644 --- a/crates/text2/src/text2.rs +++ b/crates/text2/src/text2.rs @@ -2655,7 +2655,7 @@ impl LineEnding { max_ix -= 1; } - if let Some(ix) = text[..max_ix].find(&['\n']) { + if let Some(ix) = text[..max_ix].find(['\n']) { if ix > 0 && text.as_bytes()[ix - 1] == b'\r' { Self::Windows } else { diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs index 19b244383f..7e8444f979 100644 --- a/crates/util/src/paths.rs +++ b/crates/util/src/paths.rs @@ -67,8 +67,8 @@ impl> PathExt for T { fn icon_suffix(&self) -> Option<&str> { let file_name = self.as_ref().file_name()?.to_str()?; - if file_name.starts_with(".") { - return file_name.strip_prefix("."); + if file_name.starts_with('.') { + return file_name.strip_prefix('.'); } self.as_ref() @@ -213,7 +213,7 @@ impl Eq for PathMatcher {} impl PathMatcher { pub fn new(maybe_glob: &str) -> Result { Ok(PathMatcher { - glob: Glob::new(&maybe_glob)?.compile_matcher(), + glob: Glob::new(maybe_glob)?.compile_matcher(), maybe_path: PathBuf::from(maybe_glob), }) }