mirror of
https://gitlab.com/arnekeller/ascii-table.git
synced 2024-12-04 21:49:08 +00:00
save game
This commit is contained in:
parent
1f5dab68d2
commit
d930d332d0
@ -13,5 +13,8 @@ readme = "readme.md"
|
||||
categories = ["command-line-interface"]
|
||||
keywords = ["ascii", "table"]
|
||||
|
||||
[dependencies]
|
||||
regex = "1"
|
||||
|
||||
[dev-dependencies]
|
||||
colorful = "0.2"
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user