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() }