chore: fix clippy lints for rope2, sum_tree, text2 and util

Piotr Osiewicz created

Change summary

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(-)

Detailed changes

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,

crates/sum_tree/src/tree_map.rs 🔗

@@ -40,7 +40,7 @@ impl<K: Clone + Debug + Default + Ord, V: Clone + Debug> TreeMap<K, V> {
         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::<MapKeyRef<'_, K>>();
         cursor.seek(&MapKeyRef(Some(key)), Bias::Left, &());
         if let Some(item) = cursor.item() {
@@ -98,9 +98,7 @@ impl<K: Clone + Debug + Default + Ord, V: Clone + Debug> TreeMap<K, V> {
         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<F, T>(&mut self, key: &K, f: F) -> Option<T>

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) {

crates/text2/src/subscription.rs 🔗

@@ -18,7 +18,7 @@ impl Topic {
     }
 
     pub fn publish(&self, edits: impl Clone + IntoIterator<Item = Edit<usize>>) {
-        publish(&mut *self.0.lock(), edits);
+        publish(&mut self.0.lock(), edits);
     }
 
     pub fn publish_mut(&mut self, edits: impl Clone + IntoIterator<Item = Edit<usize>>) {

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 {

crates/util/src/paths.rs 🔗

@@ -67,8 +67,8 @@ impl<T: AsRef<Path>> 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<Self, globset::Error> {
         Ok(PathMatcher {
-            glob: Glob::new(&maybe_glob)?.compile_matcher(),
+            glob: Glob::new(maybe_glob)?.compile_matcher(),
             maybe_path: PathBuf::from(maybe_glob),
         })
     }