pub struct LineSeparator { /* private fields */ }
Expand description
Contains the character used for printing a line separator
Implementations§
Source§impl LineSeparator
impl LineSeparator
Sourcepub fn new(line: char, junc: char, ljunc: char, rjunc: char) -> LineSeparator
pub fn new(line: char, junc: char, ljunc: char, rjunc: char) -> LineSeparator
Create a new line separator instance where line
is the character used to separate 2 lines
and junc
is the one used for junctions between columns and lines
Examples found in repository?
examples/formatting.rs (line 58)
3fn main() {
4 let mut table = table!(["Value 1", "Value 2"], ["Value three", "Value four"]);
5 table.set_titles(row!["Title 1", "Title 2"]);
6
7 // Print
8 // +-------------+------------+
9 // | Title 1 | Title 2 |
10 // +-------------+------------+
11 // | Value 1 | Value 2 |
12 // | Value three | Value four |
13 // +-------------+------------+
14 println!("FORMAT_NO_LINESEP_WITH_TITLE :");
15 table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
16 table.printstd();
17 println!("");
18
19 // Print
20 // -------------------------
21 // Title 1 Title 2
22 // =========================
23 // Value 1 Value 2
24 // -------------------------
25 // Value three Value four
26 // -------------------------
27 println!("FORMAT_NO_COLSEP :");
28 table.set_format(*format::consts::FORMAT_NO_COLSEP);
29 table.printstd();
30 println!("");
31
32 // Print
33 // +-------------------------+
34 // | Title 1 Title 2 |
35 // +=========================+
36 // | Value 1 Value 2 |
37 // | Value three Value four |
38 // +-------------------------+
39 println!("FORMAT_BORDERS_ONLY :");
40 table.set_format(*format::consts::FORMAT_BORDERS_ONLY);
41 table.printstd();
42 println!("");
43
44 // Custom format can be implemented using `prettytable::format::FormatBuilder`
45 // Example to print
46 // +-------------+------------+
47 // | Title 1 | Title 2 |
48 // | Value 1 | Value 2 |
49 // | Value three | Value four |
50 // +-------------+------------+
51 println!("Custom :");
52 table.set_format(
53 format::FormatBuilder::new()
54 .column_separator('|')
55 .borders('|')
56 .separators(
57 &[format::LinePosition::Top, format::LinePosition::Bottom],
58 format::LineSeparator::new('-', '+', '+', '+'),
59 )
60 .padding(1, 1)
61 .build(),
62 );
63 table.printstd();
64
65 // Customized format with unicode
66 // Example to print
67 // ┌─────────────┬────────────┐
68 // │ Title 1 │ Title 2 │
69 // ├─────────────┼────────────┤
70 // │ Value 1 │ Value 2 │
71 // ├─────────────┼────────────┤
72 // │ Value three │ Value four │
73 // └─────────────┴────────────┘
74 println!("With unicode:");
75 table.set_format(
76 format::FormatBuilder::new()
77 .column_separator('│')
78 .borders('│')
79 .separators(
80 &[format::LinePosition::Top],
81 format::LineSeparator::new('─', '┬', '┌', '┐'),
82 )
83 .separators(
84 &[format::LinePosition::Intern],
85 format::LineSeparator::new('─', '┼', '├', '┤'),
86 )
87 .separators(
88 &[format::LinePosition::Bottom],
89 format::LineSeparator::new('─', '┴', '└', '┘'),
90 )
91 .padding(1, 1)
92 .build(),
93 );
94 table.printstd();
95
96 // Customized format with unicode and different padding
97 // Example to print
98 // ┌───────────────┬──────────────┐
99 // │ Title 1 │ Title 2 │
100 // ├───────────────┼──────────────┤
101 // │ Value 1 │ Value 2 │
102 // ├───────────────┼──────────────┤
103 // │ Value three │ Value four │
104 // └───────────────┴──────────────┘
105 // Change individual format settings
106 println!("With unicode and padding:");
107 table.get_format().padding(2, 2);
108 table.printstd();
109}
Trait Implementations§
Source§impl Clone for LineSeparator
impl Clone for LineSeparator
Source§fn clone(&self) -> LineSeparator
fn clone(&self) -> LineSeparator
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for LineSeparator
impl Debug for LineSeparator
Source§impl Default for LineSeparator
impl Default for LineSeparator
Source§impl Hash for LineSeparator
impl Hash for LineSeparator
Source§impl PartialEq for LineSeparator
impl PartialEq for LineSeparator
impl Copy for LineSeparator
impl Eq for LineSeparator
impl StructuralPartialEq for LineSeparator
Auto Trait Implementations§
impl Freeze for LineSeparator
impl RefUnwindSafe for LineSeparator
impl Send for LineSeparator
impl Sync for LineSeparator
impl Unpin for LineSeparator
impl UnwindSafe for LineSeparator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more