Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
chore: fix clippy lints for rope2, sum_tree, text2 and util
Piotr Osiewicz4fa28b3de221
diff --git a/crates/rope2/src/rope2.rs b/crates/rope2/src/rope2.rsindex 4cea1d47590..adfcd19a6c5 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.rsindex edb9010e50e..f39e3ed19a9 100644--- a/crates/sum_tree/src/tree_map.rs+++ b/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>diff --git a/crates/text2/src/locator.rs b/crates/text2/src/locator.rsindex 07b73ace05d..0fb2fa5d16e 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.rsindex b636dfcc923..878e8a2cfe0 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<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>>) {diff --git a/crates/text2/src/text2.rs b/crates/text2/src/text2.rsindex c05ea1109c0..f0931a76724 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.rsindex 19b244383fd..7e8444f979b 100644--- a/crates/util/src/paths.rs+++ b/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),})}