From d9ef764eaa5a826de9117ae835d61d116338cbf5 Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Fri, 15 Aug 2025 06:17:25 +0200 Subject: [PATCH] Fix clippy warnings --- .../practice/book-store/.meta/example.rs | 60 +++++++++---------- exercises/practice/list-ops/.meta/example.rs | 8 +-- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/exercises/practice/book-store/.meta/example.rs b/exercises/practice/book-store/.meta/example.rs index 0293a5c89..2875827e1 100644 --- a/exercises/practice/book-store/.meta/example.rs +++ b/exercises/practice/book-store/.meta/example.rs @@ -124,40 +124,40 @@ impl Iterator for DecomposeGroups { // then move the last item from the most populous group into a new group, alone, // and return let return_value = self.next.clone(); - if let Some(groups) = self.next.take() { - if !(groups.is_empty() || groups.iter().all(|g| g.0.borrow().len() == 1)) { - let mut hypothetical; - for mpg_book in groups[0].0.borrow().iter() { - for (idx, other_group) in groups[1..].iter().enumerate() { - if !other_group.0.borrow().contains(mpg_book) { - hypothetical = groups.clone(); - hypothetical[0].0.borrow_mut().remove(mpg_book); - hypothetical[1 + idx].0.borrow_mut().insert(*mpg_book); - hypothetical.sort(); - let hypothetical_hash = hash_of(&hypothetical); - if !self.prev_states.contains(&hypothetical_hash) { - self.prev_states.insert(hypothetical_hash); - self.next = Some(hypothetical); - return return_value; - } + if let Some(groups) = self.next.take() + && !(groups.is_empty() || groups.iter().all(|g| g.0.borrow().len() == 1)) + { + let mut hypothetical; + for mpg_book in groups[0].0.borrow().iter() { + for (idx, other_group) in groups[1..].iter().enumerate() { + if !other_group.0.borrow().contains(mpg_book) { + hypothetical = groups.clone(); + hypothetical[0].0.borrow_mut().remove(mpg_book); + hypothetical[1 + idx].0.borrow_mut().insert(*mpg_book); + hypothetical.sort(); + let hypothetical_hash = hash_of(&hypothetical); + if !self.prev_states.contains(&hypothetical_hash) { + self.prev_states.insert(hypothetical_hash); + self.next = Some(hypothetical); + return return_value; } } } - // we've gone through all the items of the most populous group, - // and none of them can be added to any other existing group. - // We need to create a new group; - let book = { - let backing_bt = groups[0].0.borrow(); - let mut book_iter = backing_bt.iter(); - *book_iter.next().unwrap() - }; - hypothetical = groups; - hypothetical[0].0.borrow_mut().remove(&book); - hypothetical.push(Group::new_containing(book)); - hypothetical.sort(); - self.prev_states.insert(hash_of(&hypothetical)); - self.next = Some(hypothetical); } + // we've gone through all the items of the most populous group, + // and none of them can be added to any other existing group. + // We need to create a new group; + let book = { + let backing_bt = groups[0].0.borrow(); + let mut book_iter = backing_bt.iter(); + *book_iter.next().unwrap() + }; + hypothetical = groups; + hypothetical[0].0.borrow_mut().remove(&book); + hypothetical.push(Group::new_containing(book)); + hypothetical.sort(); + self.prev_states.insert(hash_of(&hypothetical)); + self.next = Some(hypothetical); } return_value } diff --git a/exercises/practice/list-ops/.meta/example.rs b/exercises/practice/list-ops/.meta/example.rs index b32322a30..157b04dbe 100644 --- a/exercises/practice/list-ops/.meta/example.rs +++ b/exercises/practice/list-ops/.meta/example.rs @@ -32,10 +32,10 @@ where type Item = T; fn next(&mut self) -> Option { - if let Some(nested_iterator) = self.cur.as_mut() { - if let Some(val) = nested_iterator.next() { - return Some(val); - } + if let Some(nested_iterator) = self.cur.as_mut() + && let Some(val) = nested_iterator.next() + { + return Some(val); } if let Some(next_nested) = self.nested_list.next() {