MCPcopy Create free account
hub / github.com/devashishdxt/cli-table / print_horizontal_line

Function print_horizontal_line

cli-table/src/utils.rs:92–130  ·  view source on GitHub ↗
(
    buffers: &mut Buffers<'_>,
    line: Option<&HorizontalLine>,
    table_dimension: &TableDimension,
    table_format: &TableFormat,
    color_spec: &ColorSpec,
)

Source from the content-addressed store, hash-verified

90}
91
92pub(crate) fn print_horizontal_line(
93 buffers: &mut Buffers<'_>,
94 line: Option<&HorizontalLine>,
95 table_dimension: &TableDimension,
96 table_format: &TableFormat,
97 color_spec: &ColorSpec,
98) -> Result<()> {
99 if let Some(line) = line {
100 if table_format.border.left.is_some() {
101 print_char(buffers, line.left_end, color_spec)?;
102 }
103
104 let mut widths = table_dimension.widths.iter().peekable();
105
106 while let Some(width) = widths.next() {
107 let s = std::iter::repeat_n(line.filler, width + 2).collect::<String>();
108 print_str(buffers, &s, color_spec)?;
109
110 match widths.peek() {
111 Some(_) => {
112 if table_format.separator.column.is_some() {
113 print_char(buffers, line.junction, color_spec)?
114 }
115 }
116 None => {
117 if table_format.border.right.is_some() {
118 print_char(buffers, line.right_end, color_spec)?;
119 } else {
120 print_str(buffers, "", color_spec)?;
121 }
122 }
123 }
124 }
125
126 println(buffers)?;
127 }
128
129 Ok(())
130}
131
132pub(crate) fn print_vertical_line(
133 buffers: &mut Buffers<'_>,

Callers 1

buffersMethod · 0.85

Calls 3

print_charFunction · 0.85
print_strFunction · 0.85
printlnFunction · 0.85

Tested by

no test coverage detected