@@ -63,20 +63,14 @@ impl TableStruct {
63
63
64
64
fn required_dimension ( & self ) -> Dimension {
65
65
let mut heights = Vec :: with_capacity ( self . rows . len ( ) + 1 ) ;
66
+ let mut widths = Vec :: new ( ) ;
66
67
67
- let row_dimension = match self . title {
68
- Some ( ref title) => title. required_dimension ( ) ,
69
- None => {
70
- if self . rows . is_empty ( ) {
71
- Default :: default ( )
72
- } else {
73
- self . rows [ 0 ] . required_dimension ( )
74
- }
75
- }
76
- } ;
68
+ let title_dimension = self . title . as_ref ( ) . map ( RowStruct :: required_dimension) ;
77
69
78
- let mut widths = row_dimension. widths ;
79
- heights. push ( row_dimension. height ) ;
70
+ if let Some ( title_dimension) = title_dimension {
71
+ widths = title_dimension. widths ;
72
+ heights. push ( title_dimension. height ) ;
73
+ }
80
74
81
75
for row in self . rows . iter ( ) {
82
76
let row_dimension = row. required_dimension ( ) ;
@@ -85,11 +79,17 @@ impl TableStruct {
85
79
86
80
let new_widths = row_dimension. widths ;
87
81
88
- for ( width, new_width) in widths. iter_mut ( ) . zip ( new_widths. into_iter ( ) ) {
89
- * width = std:: cmp:: max ( new_width, * width) ;
82
+ if widths. is_empty ( ) {
83
+ widths = new_widths;
84
+ } else {
85
+ for ( width, new_width) in widths. iter_mut ( ) . zip ( new_widths. into_iter ( ) ) {
86
+ * width = std:: cmp:: max ( new_width, * width) ;
87
+ }
90
88
}
91
89
}
92
90
91
+ println ! ( "heights: {:?}, widths: {:?}" , heights, widths) ;
92
+
93
93
Dimension { widths, heights }
94
94
}
95
95
0 commit comments