From d930d332d031220ecdd8189a1d8faa217a87fcfd Mon Sep 17 00:00:00 2001 From: Gerrit Viljoen Date: Sat, 16 May 2020 21:56:52 +0200 Subject: [PATCH] save game --- Cargo.toml | 3 +++ src/lib.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ed8ad55..96ab8a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,5 +13,8 @@ readme = "readme.md" categories = ["command-line-interface"] keywords = ["ascii", "table"] +[dependencies] +regex = "1" + [dev-dependencies] colorful = "0.2" diff --git a/src/lib.rs b/src/lib.rs index 1e10fc2..c5da011 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -225,14 +225,14 @@ impl AsciiTable { let result: Vec<_> = (0..num_cols).map(|a| { let default_conf = &DEFAULT_COLUMN; let conf = self.columns.get(&a).unwrap_or(default_conf); - let column_width = data.iter().map(|row| Self::count_characters(&row[a])).max().unwrap(); + let column_width = data.iter().map(|row| self.count_characters(&row[a])).max().unwrap(); let header_width = conf.header.chars().count(); column_width.max(header_width).min(conf.max_width) }).collect(); self.truncate_widths(result) } - fn count_characters(cell: &str) -> usize { + fn count_characters(&self, cell: &str) -> usize { cell.chars().count() }