Skip to content

Commit

Permalink
flip cols/rows in out of range panic (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacCloos authored Aug 22, 2022
1 parent 3c02c36 commit a74d57d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a74d57d

Please sign in to comment.