mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-22 20:15:11 +00:00
Extract method for table widths total
This commit is contained in:
parent
1b58f012e0
commit
fec4c45301
@ -61,7 +61,6 @@
|
||||
|
||||
|
||||
use std::io::{Write, Error as IOError, Result as IOResult};
|
||||
use std::ops::Add;
|
||||
use std::path::PathBuf;
|
||||
use std::vec::IntoIter as VecIntoIter;
|
||||
|
||||
@ -320,7 +319,7 @@ impl<'a> Render<'a> {
|
||||
pub fn iterate_with_table(&'a self, table: Table<'a>, rows: Vec<Row>) -> TableIter<'a> {
|
||||
TableIter {
|
||||
tree_trunk: TreeTrunk::default(),
|
||||
total_width: table.columns_count() + table.widths().iter().fold(0, Add::add),
|
||||
total_width: table.widths().total(),
|
||||
table: table,
|
||||
inner: rows.into_iter(),
|
||||
colours: self.colours,
|
||||
|
@ -90,12 +90,8 @@ impl<'a, 'f> Table<'a> {
|
||||
Table { columns, colours, env, widths }
|
||||
}
|
||||
|
||||
pub fn columns_count(&self) -> usize {
|
||||
self.columns.len()
|
||||
}
|
||||
|
||||
pub fn widths(&self) -> &[usize] {
|
||||
&*self.widths
|
||||
pub fn widths(&self) -> &TableWidths {
|
||||
&self.widths
|
||||
}
|
||||
|
||||
pub fn header_row(&self) -> Row {
|
||||
@ -185,4 +181,8 @@ impl TableWidths {
|
||||
*old_width = max(*old_width, *cell.width);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn total(&self) -> usize {
|
||||
self.0.len() + self.0.iter().sum::<usize>()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user