From a1cec2cd60d64208caa2cbd11d8e6f885e80f630 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 17 May 2023 13:01:37 +0200 Subject: Split format_table into separate crate and reduce k2v-client dependencies --- src/util/formater.rs | 32 -------------------------------- src/util/lib.rs | 1 - 2 files changed, 33 deletions(-) delete mode 100644 src/util/formater.rs (limited to 'src/util') diff --git a/src/util/formater.rs b/src/util/formater.rs deleted file mode 100644 index 2ea53ebb..00000000 --- a/src/util/formater.rs +++ /dev/null @@ -1,32 +0,0 @@ -pub fn format_table_to_string(data: Vec) -> String { - let data = data - .iter() - .map(|s| s.split('\t').collect::>()) - .collect::>(); - - let columns = data.iter().map(|row| row.len()).fold(0, std::cmp::max); - let mut column_size = vec![0; columns]; - - let mut out = String::new(); - - for row in data.iter() { - for (i, col) in row.iter().enumerate() { - column_size[i] = std::cmp::max(column_size[i], col.chars().count()); - } - } - - for row in data.iter() { - for (col, col_len) in row[..row.len() - 1].iter().zip(column_size.iter()) { - out.push_str(col); - (0..col_len - col.chars().count() + 2).for_each(|_| out.push(' ')); - } - out.push_str(row[row.len() - 1]); - out.push('\n'); - } - - out -} - -pub fn format_table(data: Vec) { - print!("{}", format_table_to_string(data)); -} diff --git a/src/util/lib.rs b/src/util/lib.rs index c9110fb2..15f0f829 100644 --- a/src/util/lib.rs +++ b/src/util/lib.rs @@ -10,7 +10,6 @@ pub mod crdt; pub mod data; pub mod encode; pub mod error; -pub mod formater; pub mod forwarded_headers; pub mod metrics; pub mod migrate; -- cgit v1.2.3