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

Method required_dimension

cli-table/src/table.rs:80–108  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

78 }
79
80 fn required_dimension(&self) -> Dimension {
81 let mut heights = Vec::with_capacity(self.rows.len() + 1);
82 let mut widths = Vec::new();
83
84 let title_dimension = self.title.as_ref().map(RowStruct::required_dimension);
85
86 if let Some(title_dimension) = title_dimension {
87 widths = title_dimension.widths;
88 heights.push(title_dimension.height);
89 }
90
91 for row in self.rows.iter() {
92 let row_dimension = row.required_dimension();
93
94 heights.push(row_dimension.height);
95
96 let new_widths = row_dimension.widths;
97
98 if widths.is_empty() {
99 widths = new_widths;
100 } else {
101 for (width, new_width) in widths.iter_mut().zip(new_widths.into_iter()) {
102 *width = std::cmp::max(new_width, *width);
103 }
104 }
105 }
106
107 Dimension { widths, heights }
108 }
109
110 fn buffers(&self, writer: &BufferWriter) -> Result<Vec<Buffer>> {
111 let table_dimension = self.required_dimension();

Callers 1

buffersMethod · 0.45

Calls 2

pushMethod · 0.80
into_iterMethod · 0.80

Tested by

no test coverage detected