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