ElyTable: the import scan keeps one row at a time, not the whole file (T-14)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 19:53:50 -04:00
1 parent 843657a6b3
commit f27e73575d
3 files changed
+9 -10

No files matched your search

+6 -8
View File
@@ -154,22 +154,20 @@ fn decode(bytes: &[u8], encoding: Encoding) -> Option<String> {
.map(|text| text.into_owned())
}
/// Rows as Calc's text import reads them (impex.cxx).
fn split(text: &str, how: &Import) -> Vec<Vec<String>> {
/// Calc's text-import rows (impex.cxx), one at a time.
fn split<'a>(text: &'a str, how: &'a Import) -> impl Iterator<Item = Vec<String>> + 'a {
let mut chars = text.chars().peekable();
let mut rows = Vec::new();
while chars.peek().is_some() {
std::iter::from_fn(move || {
chars.peek()?;
let mut row = Vec::new();
loop {
let (value, more) = field(&mut chars, how);
row.push(value);
if !more {
break;
return Some(row);
}
}
rows.push(row);
}
rows
})
}
/// One field, and whether the record goes on.