diff options
-rw-r--r-- | examples/formatting.rs | 24 | ||||
-rw-r--r-- | src/lib.rs | 12 |
2 files changed, 25 insertions, 11 deletions
diff --git a/examples/formatting.rs b/examples/formatting.rs index a3cbc51..7822866 100644 --- a/examples/formatting.rs +++ b/examples/formatting.rs @@ -64,16 +64,16 @@ fn main() { // Customized format with unicode // Example to print // ┌─────────────┬────────────┐ - // | Title 1 | Title 2 | + // │ Title 1 │ Title 2 │ // ├─────────────┼────────────┤ - // | Value 1 | Value 2 | + // │ Value 1 │ Value 2 │ // ├─────────────┼────────────┤ - // | Value three | Value four | + // │ Value three │ Value four │ // └─────────────┴────────────┘ println!("With unicode:"); table.set_format(format::FormatBuilder::new() - .column_separator('|') - .borders('|') + .column_separator('│') + .borders('│') .separators(&[format::LinePosition::Top], format::LineSeparator::new('─', '┬', '┌', '┐')) .separators(&[format::LinePosition::Intern], @@ -83,4 +83,18 @@ fn main() { .padding(1, 1) .build()); table.printstd(); + + // Customized format with unicode and different padding + // Example to print + // ┌───────────────┬──────────────┐ + // │ Title 1 │ Title 2 │ + // ├───────────────┼──────────────┤ + // │ Value 1 │ Value 2 │ + // ├───────────────┼──────────────┤ + // │ Value three │ Value four │ + // └───────────────┴──────────────┘ + // Change individual format settings + println!("With unicode and padding:"); + table.get_format().padding(2, 2); + table.printstd(); } @@ -862,7 +862,7 @@ mod tests { table.add_row(Row::new(vec![Cell::new("def"), Cell::new("bc"), Cell::new("a")])); table.set_titles(Row::new(vec![Cell::new("t1"), Cell::new("t2"), Cell::new("t3")])); table.get_format().indent(8); - let out = r" +-----+----+-----+ + let out = " +-----+----+-----+ | t1 | t2 | t3 | +=====+====+=====+ | a | bc | def | @@ -905,8 +905,8 @@ mod tests { fn test_unicode_separators() { let mut table = Table::new(); table.set_format(format::FormatBuilder::new() - .column_separator('|') - .borders('|') + .column_separator('│') + .borders('│') .separators(&[format::LinePosition::Top], format::LineSeparator::new('─', '┬', @@ -929,11 +929,11 @@ mod tests { table.set_titles(Row::new(vec![Cell::new("t1"), Cell::new("t2"), Cell::new("t3")])); let out = "\ ┌────┬────┬────┐ -| t1 | t2 | t3 | +│ t1 │ t2 │ t3 │ ├────┼────┼────┤ -| 1 | 1 | 1 | +│ 1 │ 1 │ 1 │ ├────┼────┼────┤ -| 2 | 2 | 2 | +│ 2 │ 2 │ 2 │ └────┴────┴────┘ "; println!("{}", out); |