From 2aa9ef947fa4104deef034305f1238275427a092 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 19 Aug 2024 00:17:14 -0700 Subject: [PATCH 1/1] Read multiple row headers --- src/lib.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0584cd2..1d098b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,15 +11,10 @@ struct RowInput { #[cfg(test)] fn read_rows(input: impl std::io::Read) -> impl Iterator { - vec![RowInput { - label: std::io::BufReader::new(input) - .lines() - .nth(0) - .unwrap() - .unwrap(), + std::io::BufReader::new(input).lines().map(|line| RowInput { + label: line.unwrap(), entries: vec![], - }] - .into_iter() + }) } pub fn tablify(_input: &impl std::io::Read) -> String { @@ -46,5 +41,18 @@ mod tests { entries: vec![] }] ); + assert_eq!( + read_rows(&b"foo\nbar\n"[..]).collect::>(), + vec![ + RowInput { + label: String::from("foo"), + entries: vec![] + }, + RowInput { + label: String::from("bar"), + entries: vec![] + } + ] + ); } } -- 2.44.1