@@ -130,6 +130,11 @@ impl<T: AsRef<str>> Grid<T> {
130
130
self . dimensions . num_lines
131
131
}
132
132
133
+ /// The width of each column
134
+ pub fn column_widths ( & self ) -> & [ usize ] {
135
+ & self . dimensions . widths
136
+ }
137
+
133
138
/// Returns whether this display takes up as many columns as were allotted
134
139
/// to it.
135
140
///
@@ -141,7 +146,7 @@ impl<T: AsRef<str>> Grid<T> {
141
146
self . dimensions . widths . iter ( ) . all ( |& x| x > 0 )
142
147
}
143
148
144
- fn column_widths ( & self , num_lines : usize , num_columns : usize ) -> Dimensions {
149
+ fn compute_dimensions ( & self , num_lines : usize , num_columns : usize ) -> Dimensions {
145
150
let mut column_widths = vec ! [ 0 ; num_columns] ;
146
151
for ( index, cell_width) in self . widths . iter ( ) . copied ( ) . enumerate ( ) {
147
152
let index = match self . options . direction {
@@ -238,7 +243,7 @@ impl<T: AsRef<str>> Grid<T> {
238
243
// Remove the separator width from the available space.
239
244
let adjusted_width = maximum_width - total_separator_width;
240
245
241
- let potential_dimensions = self . column_widths ( num_lines, num_columns) ;
246
+ let potential_dimensions = self . compute_dimensions ( num_lines, num_columns) ;
242
247
if potential_dimensions. widths . iter ( ) . sum :: < usize > ( ) <= adjusted_width {
243
248
smallest_dimensions_yet = Some ( potential_dimensions) ;
244
249
} else {
0 commit comments