Skip to content

Commit

Permalink
fix: sort cells by (row, col) to ensure row_end - row_start >= 0
Browse files Browse the repository at this point in the history
  • Loading branch information
sftse committed Aug 29, 2024
1 parent 03e16e1 commit e5de6be
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ impl<T: CellType> Range<T> {
///
/// panics when a `Cell` row is lower than the first `Cell` row or
/// bigger than the last `Cell` row.
pub fn from_sparse(cells: Vec<Cell<T>>) -> Range<T> {
pub fn from_sparse(mut cells: Vec<Cell<T>>) -> Range<T> {
cells.sort_by_key(|cell| (cell.pos.0, cell.pos.1));
if cells.is_empty() {
Range::empty()
} else {
Expand Down

0 comments on commit e5de6be

Please sign in to comment.