dont actually print spaces if requested
This commit is contained in:
parent
1b57a0b297
commit
da124869ca
|
@ -32,6 +32,14 @@ pub struct Col {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Col {
|
impl Col {
|
||||||
|
pub fn new() -> Col {
|
||||||
|
Col {
|
||||||
|
min_width: 0,
|
||||||
|
align: Align::Left,
|
||||||
|
max_width: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn min_width(size: usize) -> Col {
|
pub fn min_width(size: usize) -> Col {
|
||||||
Col {
|
Col {
|
||||||
min_width: size,
|
min_width: size,
|
||||||
|
@ -125,7 +133,11 @@ impl Tabulate {
|
||||||
|
|
||||||
self.data.into_iter().map(|row| match row {
|
self.data.into_iter().map(|row| match row {
|
||||||
DataOrSep::Sep(c) => {
|
DataOrSep::Sep(c) => {
|
||||||
c.to_string().repeat(widths.iter().sum::<usize>() + widths.len() -1) + "\n"
|
if c == ' ' {
|
||||||
|
"\n".into()
|
||||||
|
} else {
|
||||||
|
c.to_string().repeat(widths.iter().sum::<usize>() + widths.len() -1) + "\n"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
DataOrSep::Data(d) => {
|
DataOrSep::Data(d) => {
|
||||||
d.into_iter().zip(widths.iter()).zip(cols.iter()).map(|((d, &w), &c)| {
|
d.into_iter().zip(widths.iter()).zip(cols.iter()).map(|((d, &w), &c)| {
|
||||||
|
@ -339,6 +351,27 @@ Sun Oct 05, 2008 16:00:00 - 18:00:00 2:00:00 quiúbole
|
||||||
2:00:00
|
2:00:00
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
Total 2:00:00
|
Total 2:00:00
|
||||||
|
"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tabulate_a_blank_row() {
|
||||||
|
let mut tabs = Tabulate::with_columns(vec![
|
||||||
|
Col::new()
|
||||||
|
]);
|
||||||
|
|
||||||
|
tabs.feed(vec!["Hola".into()]);
|
||||||
|
tabs.separator(' ');
|
||||||
|
tabs.feed(vec!["adiós".into()]);
|
||||||
|
tabs.separator('-');
|
||||||
|
tabs.feed(vec!["ta güeno".into()]);
|
||||||
|
|
||||||
|
assert_eq!(PrettyString(&tabs.print()), PrettyString("\
|
||||||
|
Hola
|
||||||
|
|
||||||
|
adiós
|
||||||
|
--------
|
||||||
|
ta güeno
|
||||||
"));
|
"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue