Skip to content

Fix clippy warnings #2091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions exercises/practice/book-store/.meta/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/list-ops/.meta/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ where
type Item = T;

fn next(&mut self) -> Option<Self::Item> {
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() {
Expand Down