One big cleanup pass of clippy lints

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
ForLoveOfCats 2022-08-10 17:39:24 -04:00 committed by K Simmons
parent e7540d2833
commit 8ba2f77148
138 changed files with 1328 additions and 1366 deletions

View file

@ -160,7 +160,7 @@ where
let mut descending = false;
while !self.stack.is_empty() {
if let Some(StackEntry { position, .. }) = self.stack.iter().rev().skip(1).next() {
if let Some(StackEntry { position, .. }) = self.stack.iter().rev().nth(1) {
self.position = position.clone();
} else {
self.position = D::default();
@ -224,7 +224,7 @@ where
self.did_seek = true;
}
while self.stack.len() > 0 {
while !self.stack.is_empty() {
let new_subtree = {
let entry = self.stack.last_mut().unwrap();
match entry.tree.0.as_ref() {
@ -409,7 +409,7 @@ where
.zip(&child_summaries[entry.index..])
{
let mut child_end = self.position.clone();
child_end.add_summary(&child_summary, cx);
child_end.add_summary(child_summary, cx);
let comparison = target.cmp(&child_end, cx);
if comparison == Ordering::Greater
@ -503,7 +503,7 @@ impl<'a, T: Item> Iterator for Iter<'a, T> {
descend = true;
}
while self.stack.len() > 0 {
while !self.stack.is_empty() {
let new_subtree = {
let entry = self.stack.last_mut().unwrap();
match entry.tree.0.as_ref() {

View file

@ -304,7 +304,7 @@ impl<T: Item> SumTree<T> {
}
pub fn push_tree(&mut self, other: Self, cx: &<T::Summary as Summary>::Context) {
if !other.0.is_leaf() || other.0.items().len() > 0 {
if !other.0.is_leaf() || !other.0.items().is_empty() {
if self.0.height() < other.0.height() {
for tree in other.0.child_trees() {
self.push_tree(tree.clone(), cx);
@ -610,10 +610,7 @@ pub enum Node<T: Item> {
impl<T: Item> Node<T> {
fn is_leaf(&self) -> bool {
match self {
Node::Leaf { .. } => true,
_ => false,
}
matches!(self, Node::Leaf { .. })
}
fn height(&self) -> u8 {
@ -786,8 +783,7 @@ mod tests {
while item_ix < expected_filtered_items.len() {
log::info!("filter_cursor, item_ix: {}", item_ix);
let actual_item = filter_cursor.item().unwrap();
let (reference_index, reference_item) =
expected_filtered_items[item_ix].clone();
let (reference_index, reference_item) = expected_filtered_items[item_ix];
assert_eq!(actual_item, &reference_item);
assert_eq!(filter_cursor.start().0, reference_index);
log::info!("next");

View file

@ -73,7 +73,7 @@ impl<K: Clone + Debug + Default + Ord, V: Clone + Debug> TreeMap<K, V> {
removed
}
pub fn iter<'a>(&'a self) -> impl 'a + Iterator<Item = (&'a K, &'a V)> {
pub fn iter(&self) -> impl Iterator<Item = (&K, &V)> + '_ {
self.0.iter().map(|entry| (&entry.key, &entry.value))
}
}
@ -162,7 +162,7 @@ where
self.0.get(key).is_some()
}
pub fn iter<'a>(&'a self) -> impl 'a + Iterator<Item = &'a K> {
pub fn iter(&self) -> impl Iterator<Item = &K> + '_ {
self.0.iter().map(|(k, _)| k)
}
}