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

This commit is contained in:
Piotr Osiewicz 2024-01-01 23:50:14 +01:00
parent 219999cd8d
commit 4fa28b3de2
6 changed files with 10 additions and 12 deletions

View file

@ -906,7 +906,7 @@ impl Chunk {
fn clip_offset_utf16(&self, target: OffsetUtf16, bias: Bias) -> OffsetUtf16 { fn clip_offset_utf16(&self, target: OffsetUtf16, bias: Bias) -> OffsetUtf16 {
let mut code_units = self.0.encode_utf16(); 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() { if char::decode_utf16(code_units).next().transpose().is_err() {
match bias { match bias {
Bias::Left => offset -= 1, Bias::Left => offset -= 1,

View file

@ -40,7 +40,7 @@ impl<K: Clone + Debug + Default + Ord, V: Clone + Debug> TreeMap<K, V> {
self.0.is_empty() 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>>(); let mut cursor = self.0.cursor::<MapKeyRef<'_, K>>();
cursor.seek(&MapKeyRef(Some(key)), Bias::Left, &()); cursor.seek(&MapKeyRef(Some(key)), Bias::Left, &());
if let Some(item) = cursor.item() { 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)); let from_key = MapKeyRef(Some(from));
cursor.seek(&from_key, Bias::Left, &()); cursor.seek(&from_key, Bias::Left, &());
cursor cursor.map(|map_entry| (&map_entry.key, &map_entry.value))
.into_iter()
.map(|map_entry| (&map_entry.key, &map_entry.value))
} }
pub fn update<F, T>(&mut self, key: &K, f: F) -> Option<T> pub fn update<F, T>(&mut self, key: &K, f: F) -> Option<T>

View file

@ -20,11 +20,11 @@ impl Locator {
} }
pub fn min_ref() -> &'static Self { pub fn min_ref() -> &'static Self {
&*MIN &MIN
} }
pub fn max_ref() -> &'static Self { pub fn max_ref() -> &'static Self {
&*MAX &MAX
} }
pub fn assign(&mut self, other: &Self) { pub fn assign(&mut self, other: &Self) {

View file

@ -18,7 +18,7 @@ impl Topic {
} }
pub fn publish(&self, edits: impl Clone + IntoIterator<Item = Edit<usize>>) { 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>>) { pub fn publish_mut(&mut self, edits: impl Clone + IntoIterator<Item = Edit<usize>>) {

View file

@ -2655,7 +2655,7 @@ impl LineEnding {
max_ix -= 1; 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' { if ix > 0 && text.as_bytes()[ix - 1] == b'\r' {
Self::Windows Self::Windows
} else { } else {

View file

@ -67,8 +67,8 @@ impl<T: AsRef<Path>> PathExt for T {
fn icon_suffix(&self) -> Option<&str> { fn icon_suffix(&self) -> Option<&str> {
let file_name = self.as_ref().file_name()?.to_str()?; let file_name = self.as_ref().file_name()?.to_str()?;
if file_name.starts_with(".") { if file_name.starts_with('.') {
return file_name.strip_prefix("."); return file_name.strip_prefix('.');
} }
self.as_ref() self.as_ref()
@ -213,7 +213,7 @@ impl Eq for PathMatcher {}
impl PathMatcher { impl PathMatcher {
pub fn new(maybe_glob: &str) -> Result<Self, globset::Error> { pub fn new(maybe_glob: &str) -> Result<Self, globset::Error> {
Ok(PathMatcher { Ok(PathMatcher {
glob: Glob::new(&maybe_glob)?.compile_matcher(), glob: Glob::new(maybe_glob)?.compile_matcher(),
maybe_path: PathBuf::from(maybe_glob), maybe_path: PathBuf::from(maybe_glob),
}) })
} }