Skip to content

Commit f73d1bf

Browse files
committed
lazycsv: Treat a row with smaller columns as a parsing error
1 parent 159ab4c commit f73d1bf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crates/lazycsv/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,17 @@ impl<'a, const COLS: usize> Iterator for CsvRowIter<'a, COLS> {
411411
let mut arr = [const { MaybeUninit::uninit() }; COLS];
412412
for i in 0..COLS {
413413
match self.csv.next() {
414+
None if i == 0 => return None,
414415
Some(CsvIterItem::Cell(cell)) => {
415416
// SAFETY: we have to initialize the cell beforehand
416417
unsafe { arr.get_unchecked_mut(i).write(cell) };
417418
}
418-
Some(CsvIterItem::LineEnd) => {
419+
None | Some(CsvIterItem::LineEnd) => {
419420
return Some(Err(RowIterError::ColumnCountSmallerThanExpected {
420421
expected: COLS,
421-
actual: i - 1,
422+
actual: i,
422423
}));
423424
}
424-
None => return None,
425425
}
426426
}
427427

0 commit comments

Comments
 (0)