From d22b2e05706f7a4367ac3df33d61383673724b8b Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 19 Aug 2024 12:55:11 -0700 Subject: [PATCH 1/1] column_order() --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5b06e70..2dd3964 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,6 +141,12 @@ fn column_counts(rows: &[RowInput]) -> Vec<(usize, String)> { counts.sort(); counts } +fn column_order(rows: &[RowInput]) -> Vec { + column_counts(rows) + .into_iter() + .map(|(_, col)| col) + .collect() +} /// # Errors /// @@ -150,7 +156,7 @@ fn column_counts(rows: &[RowInput]) -> Vec<(usize, String)> { /// * an indented line with no preceding non-indented line pub fn tablify(input: impl std::io::Read) -> Result { let rows = read_rows(input).collect::, _>>()?; - let _columns = column_counts(&rows); + let _columns = column_order(&rows); Ok(String::from(HEADER) + "Hello, world!" + FOOTER) } -- 2.44.1