Simplified with if let

This commit is contained in:
Anthony Scemama 2023-10-20 13:28:40 +02:00
parent 9496db0255
commit 2e42ebad74

View File

@ -188,19 +188,13 @@ impl<'a, T> Iterator for MatrixIter1DRow<'a, T> {
type Item = &'a T;
fn next(&mut self) -> Option<Self::Item> {
let v = self.iter.next();
match v {
Some(_) => v,
None => {
let new_row = self.row.next();
match new_row {
None => None,
Some(i) => {
self.iter = self.mat.iter_row(i);
self.iter.next()
}
}
}
if let Some(v) = self.iter.next() {
Some(v)
} else if let Some(new_row) = self.row.next() {
self.iter = self.mat.iter_row(new_row);
self.iter.next()
} else {
None
}
}
}
@ -217,9 +211,8 @@ impl<'a, T> Iterator for MatrixIter1DRowMut<'a, T> {
type Item = &'a mut T;
fn next(&mut self) -> Option<Self::Item> {
let v = self.iter.next();
match v {
Some(_) => v,
if let v = self.iter.next() {
v,
None => {
let new_row = self.row.next();
match new_row {