@@ -50,10 +50,10 @@ where
50
50
T : Serialize + Clone + Default + ' static ,
51
51
N : Serialize + Clone + Default + ' static ,
52
52
{
53
- pub fn new ( header : Vec < T > , cells : Vec < Vec < N > > ) -> Box < Self > {
53
+ pub fn new ( header : Header < T > , cells : Cells < N > ) -> Box < Self > {
54
54
Box :: new ( Table {
55
- header : Header :: new ( ) . values ( header) . into ( ) ,
56
- cells : Cells :: new ( ) . values ( cells) . into ( ) ,
55
+ header : Some ( header) ,
56
+ cells : Some ( cells) ,
57
57
..Default :: default ( )
58
58
} )
59
59
}
@@ -93,8 +93,11 @@ impl<N> Cells<N>
93
93
where
94
94
N : Serialize + Clone + Default + ' static ,
95
95
{
96
- pub fn new ( ) -> Self {
97
- Default :: default ( )
96
+ pub fn new ( values : Vec < Vec < N > > ) -> Self {
97
+ Cells {
98
+ values : Some ( values) ,
99
+ ..Default :: default ( )
100
+ }
98
101
}
99
102
}
100
103
@@ -122,8 +125,11 @@ impl<T> Header<T>
122
125
where
123
126
T : Serialize + Clone + Default + ' static ,
124
127
{
125
- pub fn new ( ) -> Self {
126
- Default :: default ( )
128
+ pub fn new ( values : Vec < T > ) -> Self {
129
+ Header {
130
+ values : Some ( values) ,
131
+ ..Default :: default ( )
132
+ }
127
133
}
128
134
}
129
135
@@ -147,9 +153,9 @@ mod tests {
147
153
148
154
#[ test]
149
155
fn test_serialize_table ( ) {
150
- let columns = vec ! [ String :: from( "col1" ) , String :: from( "col2" ) ] ;
151
- let values = vec ! [ vec![ 1 , 2 ] , vec![ 2 , 3 ] ] ;
152
- let trace = Table :: new ( columns. clone ( ) , values) ;
156
+ let columns = Header :: new ( vec ! [ String :: from( "col1" ) , String :: from( "col2" ) ] ) ;
157
+ let values = Cells :: new ( vec ! [ vec![ 1 , 2 ] , vec![ 2 , 3 ] ] ) ;
158
+ let trace = Table :: new ( columns, values) ;
153
159
154
160
let expected = json ! ( {
155
161
"type" : "table" ,
0 commit comments