Skip to content

Commit 9481373

Browse files
authored
Fix clippy warnings (#2091)
1 parent 818eb68 commit 9481373

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

exercises/practice/book-store/.meta/example.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -124,40 +124,40 @@ impl Iterator for DecomposeGroups {
124124
// then move the last item from the most populous group into a new group, alone,
125125
// and return
126126
let return_value = self.next.clone();
127-
if let Some(groups) = self.next.take() {
128-
if !(groups.is_empty() || groups.iter().all(|g| g.0.borrow().len() == 1)) {
129-
let mut hypothetical;
130-
for mpg_book in groups[0].0.borrow().iter() {
131-
for (idx, other_group) in groups[1..].iter().enumerate() {
132-
if !other_group.0.borrow().contains(mpg_book) {
133-
hypothetical = groups.clone();
134-
hypothetical[0].0.borrow_mut().remove(mpg_book);
135-
hypothetical[1 + idx].0.borrow_mut().insert(*mpg_book);
136-
hypothetical.sort();
137-
let hypothetical_hash = hash_of(&hypothetical);
138-
if !self.prev_states.contains(&hypothetical_hash) {
139-
self.prev_states.insert(hypothetical_hash);
140-
self.next = Some(hypothetical);
141-
return return_value;
142-
}
127+
if let Some(groups) = self.next.take()
128+
&& !(groups.is_empty() || groups.iter().all(|g| g.0.borrow().len() == 1))
129+
{
130+
let mut hypothetical;
131+
for mpg_book in groups[0].0.borrow().iter() {
132+
for (idx, other_group) in groups[1..].iter().enumerate() {
133+
if !other_group.0.borrow().contains(mpg_book) {
134+
hypothetical = groups.clone();
135+
hypothetical[0].0.borrow_mut().remove(mpg_book);
136+
hypothetical[1 + idx].0.borrow_mut().insert(*mpg_book);
137+
hypothetical.sort();
138+
let hypothetical_hash = hash_of(&hypothetical);
139+
if !self.prev_states.contains(&hypothetical_hash) {
140+
self.prev_states.insert(hypothetical_hash);
141+
self.next = Some(hypothetical);
142+
return return_value;
143143
}
144144
}
145145
}
146-
// we've gone through all the items of the most populous group,
147-
// and none of them can be added to any other existing group.
148-
// We need to create a new group;
149-
let book = {
150-
let backing_bt = groups[0].0.borrow();
151-
let mut book_iter = backing_bt.iter();
152-
*book_iter.next().unwrap()
153-
};
154-
hypothetical = groups;
155-
hypothetical[0].0.borrow_mut().remove(&book);
156-
hypothetical.push(Group::new_containing(book));
157-
hypothetical.sort();
158-
self.prev_states.insert(hash_of(&hypothetical));
159-
self.next = Some(hypothetical);
160146
}
147+
// we've gone through all the items of the most populous group,
148+
// and none of them can be added to any other existing group.
149+
// We need to create a new group;
150+
let book = {
151+
let backing_bt = groups[0].0.borrow();
152+
let mut book_iter = backing_bt.iter();
153+
*book_iter.next().unwrap()
154+
};
155+
hypothetical = groups;
156+
hypothetical[0].0.borrow_mut().remove(&book);
157+
hypothetical.push(Group::new_containing(book));
158+
hypothetical.sort();
159+
self.prev_states.insert(hash_of(&hypothetical));
160+
self.next = Some(hypothetical);
161161
}
162162
return_value
163163
}

exercises/practice/list-ops/.meta/example.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ where
3232
type Item = T;
3333

3434
fn next(&mut self) -> Option<Self::Item> {
35-
if let Some(nested_iterator) = self.cur.as_mut() {
36-
if let Some(val) = nested_iterator.next() {
37-
return Some(val);
38-
}
35+
if let Some(nested_iterator) = self.cur.as_mut()
36+
&& let Some(val) = nested_iterator.next()
37+
{
38+
return Some(val);
3939
}
4040

4141
if let Some(next_nested) = self.nested_list.next() {

0 commit comments

Comments
 (0)