flip cols/rows in out of range panic (#21)

This commit is contained in:
Isaac Cloos 2022-08-22 08:47:12 -04:00 committed by GitHub
parent 3c02c36274
commit a74d57dac2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -613,7 +613,7 @@ impl<T> Grid<T> {
panic!("Inserted row must be of length {}, but was {}.", self.cols, row.len());
}
if index > self.rows {
panic!("Out of range. Index was {}, but must be less or equal to {}.", index, self.cols);
panic!("Out of range. Index was {}, but must be less or equal to {}.", index, self.rows);
}
self.rows += 1;
let data_idx = index * self.cols;
@ -646,7 +646,7 @@ impl<T> Grid<T> {
panic!("Inserted col must be of length {}, but was {}.", self.rows, col.len());
}
if index > self.cols {
panic!("Out of range. Index was {}, but must be less or equal to {}.", index, self.rows);
panic!("Out of range. Index was {}, but must be less or equal to {}.", index, self.cols);
}
for (row_iter, col_val) in col.into_iter().enumerate() {
let data_idx = row_iter * self.cols + index + row_iter;