warning: unused return value of `std::iter::Iterator::collect`
The following code:
--> src/game.rs:69:9
|
69 | / self.data
70 | | .chunks_mut(4)
71 | | .map(|row| {
72 | | let (new_row, new_score) = match dir {
... |
87 | | })
88 | | .collect::<Vec<_>>();
| |_________________________________^
|
= note: #[warn(unused_must_use)] on by default
= note: if you really need to exhaust the iterator, consider `.for_each(drop)` instead
It seems that collect
is redundant. It might be better to use foreach to make the judgment of member data
self.data
.chunks_mut(4)
.map(|row| {
let (new_row, new_score) = match dir {
Direction::Right => algorithm::slide_right(row),
Direction::Left => algorithm::slide_left(row),
_ => (row.to_vec(), 0),
};
if new_score == 2048 {
won = true;
}
score += new_score;
for i in 0..4 {
if row[i] != new_row[i] {
row[i] = new_row[i];
mutated = true;
}
}
})
.collect::<Vec<_>>();