@@ -86,7 +86,7 @@ impl Field {
86
86
87
87
let vals_builder = match & self . ty {
88
88
Type :: TypePath ( _) => self . copied_direct_vals ( ) ,
89
- Type :: Option ( ref first_type) => match * * first_type {
89
+ Type :: Option ( first_type) => match * * first_type {
90
90
Type :: TypePath ( _) => self . option_into_vals ( ) ,
91
91
Type :: Reference ( _, ref second_type) => match * * second_type {
92
92
Type :: TypePath ( _) => self . option_into_vals ( ) ,
@@ -98,7 +98,7 @@ impl Field {
98
98
} ,
99
99
ref f => unimplemented ! ( "Unsupported: {:#?}" , f) ,
100
100
} ,
101
- Type :: Reference ( _, ref first_type) => match * * first_type {
101
+ Type :: Reference ( _, first_type) => match * * first_type {
102
102
Type :: TypePath ( _) => self . copied_direct_vals ( ) ,
103
103
Type :: Option ( ref second_type) => match * * second_type {
104
104
Type :: TypePath ( _) => self . option_into_vals ( ) ,
@@ -122,7 +122,7 @@ impl Field {
122
122
} ,
123
123
ref f => unimplemented ! ( "Unsupported: {:#?}" , f) ,
124
124
} ,
125
- Type :: Vec ( ref first_type) => match * * first_type {
125
+ Type :: Vec ( first_type) => match * * first_type {
126
126
Type :: TypePath ( _) => self . copied_direct_vals ( ) ,
127
127
ref f => unimplemented ! ( "Unsupported: {:#?}" , f) ,
128
128
} ,
@@ -131,7 +131,7 @@ impl Field {
131
131
132
132
let definition_levels = match & self . ty {
133
133
Type :: TypePath ( _) => None ,
134
- Type :: Option ( ref first_type) => match * * first_type {
134
+ Type :: Option ( first_type) => match * * first_type {
135
135
Type :: TypePath ( _) => Some ( self . optional_definition_levels ( ) ) ,
136
136
Type :: Option ( _) => unimplemented ! ( "Unsupported nesting encountered" ) ,
137
137
Type :: Reference ( _, ref second_type)
@@ -142,10 +142,10 @@ impl Field {
142
142
_ => unimplemented ! ( "Unsupported nesting encountered" ) ,
143
143
} ,
144
144
} ,
145
- Type :: Reference ( _, ref first_type)
146
- | Type :: Vec ( ref first_type)
147
- | Type :: Array ( ref first_type, _)
148
- | Type :: Slice ( ref first_type) => match * * first_type {
145
+ Type :: Reference ( _, first_type)
146
+ | Type :: Vec ( first_type)
147
+ | Type :: Array ( first_type, _)
148
+ | Type :: Slice ( first_type) => match * * first_type {
149
149
Type :: TypePath ( _) => None ,
150
150
Type :: Vec ( ref second_type)
151
151
| Type :: Array ( ref second_type, _)
@@ -192,15 +192,15 @@ impl Field {
192
192
// this expression just switches between non-nullable and nullable write statements
193
193
let write_batch_expr = if definition_levels. is_some ( ) {
194
194
quote ! {
195
- if let #column_writer( ref mut typed) = column_writer. untyped( ) {
195
+ if let #column_writer( typed) = column_writer. untyped( ) {
196
196
typed. write_batch( & vals[ ..] , Some ( & definition_levels[ ..] ) , None ) ?;
197
197
} else {
198
198
panic!( "Schema and struct disagree on type for {}" , stringify!{ #ident} )
199
199
}
200
200
}
201
201
} else {
202
202
quote ! {
203
- if let #column_writer( ref mut typed) = column_writer. untyped( ) {
203
+ if let #column_writer( typed) = column_writer. untyped( ) {
204
204
typed. write_batch( & vals[ ..] , None , None ) ?;
205
205
} else {
206
206
panic!( "Schema and struct disagree on type for {}" , stringify!{ #ident} )
@@ -265,15 +265,15 @@ impl Field {
265
265
// it to its field in the corresponding struct
266
266
let vals_writer = match & self . ty {
267
267
Type :: TypePath ( _) => self . copied_direct_fields ( ) ,
268
- Type :: Reference ( _, ref first_type) => match * * first_type {
268
+ Type :: Reference ( _, first_type) => match * * first_type {
269
269
Type :: TypePath ( _) => self . copied_direct_fields ( ) ,
270
270
Type :: Slice ( ref second_type) => match * * second_type {
271
271
Type :: TypePath ( _) => self . copied_direct_fields ( ) ,
272
272
ref f => unimplemented ! ( "Unsupported: {:#?}" , f) ,
273
273
} ,
274
274
ref f => unimplemented ! ( "Unsupported: {:#?}" , f) ,
275
275
} ,
276
- Type :: Vec ( ref first_type) => match * * first_type {
276
+ Type :: Vec ( first_type) => match * * first_type {
277
277
Type :: TypePath ( _) => self . copied_direct_fields ( ) ,
278
278
ref f => unimplemented ! ( "Unsupported: {:#?}" , f) ,
279
279
} ,
@@ -356,7 +356,7 @@ impl Field {
356
356
let binding = if copy_to_vec {
357
357
quote ! { let Some ( inner) = rec. #field_name }
358
358
} else {
359
- quote ! { let Some ( ref inner) = rec. #field_name }
359
+ quote ! { let Some ( inner) = & rec. #field_name }
360
360
} ;
361
361
362
362
let some = if is_a_timestamp {
@@ -545,11 +545,11 @@ impl Type {
545
545
fn leaf_type_recursive_helper < ' a > ( ty : & ' a Type , parent_ty : Option < & ' a Type > ) -> & ' a Type {
546
546
match ty {
547
547
Type :: TypePath ( _) => parent_ty. unwrap_or ( ty) ,
548
- Type :: Option ( ref first_type)
549
- | Type :: Vec ( ref first_type)
550
- | Type :: Array ( ref first_type, _)
551
- | Type :: Slice ( ref first_type)
552
- | Type :: Reference ( _, ref first_type) => {
548
+ Type :: Option ( first_type)
549
+ | Type :: Vec ( first_type)
550
+ | Type :: Array ( first_type, _)
551
+ | Type :: Slice ( first_type)
552
+ | Type :: Reference ( _, first_type) => {
553
553
Type :: leaf_type_recursive_helper ( first_type, Some ( ty) )
554
554
}
555
555
}
@@ -562,12 +562,12 @@ impl Type {
562
562
let leaf_type = self . leaf_type_recursive ( ) ;
563
563
564
564
match leaf_type {
565
- Type :: TypePath ( ref type_) => type_,
566
- Type :: Option ( ref first_type)
567
- | Type :: Vec ( ref first_type)
568
- | Type :: Array ( ref first_type, _)
569
- | Type :: Slice ( ref first_type)
570
- | Type :: Reference ( _, ref first_type) => match * * first_type {
565
+ Type :: TypePath ( type_) => type_,
566
+ Type :: Option ( first_type)
567
+ | Type :: Vec ( first_type)
568
+ | Type :: Array ( first_type, _)
569
+ | Type :: Slice ( first_type)
570
+ | Type :: Reference ( _, first_type) => match * * first_type {
571
571
Type :: TypePath ( ref type_) => type_,
572
572
_ => unimplemented ! ( "leaf_type() should only return shallow types" ) ,
573
573
} ,
@@ -612,14 +612,14 @@ impl Type {
612
612
let leaf_type = self . leaf_type_recursive ( ) ;
613
613
614
614
match leaf_type {
615
- Type :: Array ( ref first_type, _length) => {
615
+ Type :: Array ( first_type, _length) => {
616
616
if let Type :: TypePath ( _) = * * first_type {
617
617
if last_part == "u8" {
618
618
return BasicType :: FIXED_LEN_BYTE_ARRAY ;
619
619
}
620
620
}
621
621
}
622
- Type :: Vec ( ref first_type) | Type :: Slice ( ref first_type) => {
622
+ Type :: Vec ( first_type) | Type :: Slice ( first_type) => {
623
623
if let Type :: TypePath ( _) = * * first_type {
624
624
if last_part == "u8" {
625
625
return BasicType :: BYTE_ARRAY ;
@@ -654,7 +654,7 @@ impl Type {
654
654
let leaf_type = self . leaf_type_recursive ( ) ;
655
655
656
656
// `[u8; N]` => Some(N)
657
- if let Type :: Array ( ref first_type, length) = leaf_type {
657
+ if let Type :: Array ( first_type, length) = leaf_type {
658
658
if let Type :: TypePath ( _) = * * first_type {
659
659
if last_part == "u8" {
660
660
return Some ( length. clone ( ) ) ;
@@ -674,14 +674,14 @@ impl Type {
674
674
let leaf_type = self . leaf_type_recursive ( ) ;
675
675
676
676
match leaf_type {
677
- Type :: Array ( ref first_type, _length) => {
677
+ Type :: Array ( first_type, _length) => {
678
678
if let Type :: TypePath ( _) = * * first_type {
679
679
if last_part == "u8" {
680
680
return quote ! { None } ;
681
681
}
682
682
}
683
683
}
684
- Type :: Vec ( ref first_type) | Type :: Slice ( ref first_type) => {
684
+ Type :: Vec ( first_type) | Type :: Slice ( first_type) => {
685
685
if let Type :: TypePath ( _) = * * first_type {
686
686
if last_part == "u8" {
687
687
return quote ! { None } ;
@@ -764,10 +764,10 @@ impl Type {
764
764
765
765
fn from_type ( f : & syn:: Field , ty : & syn:: Type ) -> Self {
766
766
match ty {
767
- syn:: Type :: Path ( ref p) => Type :: from_type_path ( f, p) ,
768
- syn:: Type :: Reference ( ref tr) => Type :: from_type_reference ( f, tr) ,
769
- syn:: Type :: Array ( ref ta) => Type :: from_type_array ( f, ta) ,
770
- syn:: Type :: Slice ( ref ts) => Type :: from_type_slice ( f, ts) ,
767
+ syn:: Type :: Path ( p) => Type :: from_type_path ( f, p) ,
768
+ syn:: Type :: Reference ( tr) => Type :: from_type_reference ( f, tr) ,
769
+ syn:: Type :: Array ( ta) => Type :: from_type_array ( f, ta) ,
770
+ syn:: Type :: Slice ( ts) => Type :: from_type_slice ( f, ts) ,
771
771
other => unimplemented ! (
772
772
"Unable to derive {:?} - it is currently an unsupported type\n {:#?}" ,
773
773
f. ident. as_ref( ) . unwrap( ) ,
@@ -790,7 +790,7 @@ impl Type {
790
790
let first_arg = & angle_args. args [ 0 ] ;
791
791
792
792
match first_arg {
793
- syn:: GenericArgument :: Type ( ref typath) => typath. clone ( ) ,
793
+ syn:: GenericArgument :: Type ( typath) => typath. clone ( ) ,
794
794
other => unimplemented ! ( "Unsupported: {:#?}" , other) ,
795
795
}
796
796
}
@@ -857,7 +857,7 @@ mod test {
857
857
{
858
858
let vals : Vec < _ > = records . iter ( ) . map ( | rec | rec . counter as i64 ) . collect ( ) ;
859
859
860
- if let ColumnWriter :: Int64ColumnWriter ( ref mut typed ) = column_writer. untyped( ) {
860
+ if let ColumnWriter :: Int64ColumnWriter ( typed ) = column_writer. untyped( ) {
861
861
typed . write_batch ( & vals [ .. ] , None , None ) ?;
862
862
} else {
863
863
panic!( "Schema and struct disagree on type for {}" , stringify!{ counter } )
@@ -924,14 +924,14 @@ mod test {
924
924
let definition_levels : Vec < i16 > = self . iter ( ) . map ( | rec | if rec . optional_str . is_some ( ) { 1 } else { 0 } ) . collect ( ) ;
925
925
926
926
let vals: Vec <_> = records. iter( ) . filter_map( |rec| {
927
- if let Some ( ref inner ) = rec . optional_str {
927
+ if let Some ( inner ) = & rec . optional_str {
928
928
Some ( ( & inner[ ..] ) . into( ) )
929
929
} else {
930
930
None
931
931
}
932
932
} ) . collect( ) ;
933
933
934
- if let ColumnWriter :: ByteArrayColumnWriter ( ref mut typed ) = column_writer. untyped( ) {
934
+ if let ColumnWriter :: ByteArrayColumnWriter ( typed ) = column_writer. untyped( ) {
935
935
typed . write_batch ( & vals [ .. ] , Some ( & definition_levels[ ..] ) , None ) ? ;
936
936
} else {
937
937
panic!( "Schema and struct disagree on type for {}" , stringify ! { optional_str } )
@@ -948,14 +948,14 @@ mod test {
948
948
let definition_levels : Vec < i16 > = self . iter ( ) . map ( | rec | if rec . optional_string . is_some ( ) { 1 } else { 0 } ) . collect ( ) ;
949
949
950
950
let vals: Vec <_> = records. iter( ) . filter_map( |rec| {
951
- if let Some ( ref inner ) = rec . optional_string {
951
+ if let Some ( inner ) = & rec . optional_string {
952
952
Some ( ( & inner[ ..] ) . into( ) )
953
953
} else {
954
954
None
955
955
}
956
956
} ) . collect( ) ;
957
957
958
- if let ColumnWriter :: ByteArrayColumnWriter ( ref mut typed ) = column_writer. untyped( ) {
958
+ if let ColumnWriter :: ByteArrayColumnWriter ( typed ) = column_writer. untyped( ) {
959
959
typed . write_batch ( & vals [ .. ] , Some ( & definition_levels[ ..] ) , None ) ? ;
960
960
} else {
961
961
panic!( "Schema and struct disagree on type for {}" , stringify ! { optional_string } )
@@ -978,7 +978,7 @@ mod test {
978
978
}
979
979
} ) . collect( ) ;
980
980
981
- if let ColumnWriter :: Int32ColumnWriter ( ref mut typed ) = column_writer. untyped( ) {
981
+ if let ColumnWriter :: Int32ColumnWriter ( typed ) = column_writer. untyped( ) {
982
982
typed . write_batch ( & vals [ .. ] , Some ( & definition_levels[ ..] ) , None ) ? ;
983
983
} else {
984
984
panic!( "Schema and struct disagree on type for {}" , stringify ! { optional_dumb_int } )
@@ -1261,7 +1261,7 @@ mod test {
1261
1261
assert_eq ! ( when. writer_snippet( ) . to_string( ) , ( quote!{
1262
1262
{
1263
1263
let vals : Vec <_> = records. iter( ) . map( |rec| rec. henceforth. timestamp_millis( ) ) . collect( ) ;
1264
- if let ColumnWriter :: Int64ColumnWriter ( ref mut typed) = column_writer. untyped( ) {
1264
+ if let ColumnWriter :: Int64ColumnWriter ( typed) = column_writer. untyped( ) {
1265
1265
typed. write_batch( & vals[ ..] , None , None ) ?;
1266
1266
} else {
1267
1267
panic!( "Schema and struct disagree on type for {}" , stringify!{ henceforth } )
@@ -1281,7 +1281,7 @@ mod test {
1281
1281
}
1282
1282
} ) . collect( ) ;
1283
1283
1284
- if let ColumnWriter :: Int64ColumnWriter ( ref mut typed) = column_writer. untyped( ) {
1284
+ if let ColumnWriter :: Int64ColumnWriter ( typed) = column_writer. untyped( ) {
1285
1285
typed. write_batch( & vals[ ..] , Some ( & definition_levels[ ..] ) , None ) ?;
1286
1286
} else {
1287
1287
panic!( "Schema and struct disagree on type for {}" , stringify!{ maybe_happened } )
@@ -1335,7 +1335,7 @@ mod test {
1335
1335
assert_eq ! ( when. writer_snippet( ) . to_string( ) , ( quote!{
1336
1336
{
1337
1337
let vals : Vec <_> = records. iter( ) . map( |rec| rec. henceforth. signed_duration_since( :: chrono:: NaiveDate :: from_ymd( 1970 , 1 , 1 ) ) . num_days( ) as i32 ) . collect( ) ;
1338
- if let ColumnWriter :: Int32ColumnWriter ( ref mut typed) = column_writer. untyped( ) {
1338
+ if let ColumnWriter :: Int32ColumnWriter ( typed) = column_writer. untyped( ) {
1339
1339
typed. write_batch( & vals[ ..] , None , None ) ?;
1340
1340
} else {
1341
1341
panic!( "Schema and struct disagree on type for {}" , stringify!{ henceforth } )
@@ -1355,7 +1355,7 @@ mod test {
1355
1355
}
1356
1356
} ) . collect( ) ;
1357
1357
1358
- if let ColumnWriter :: Int32ColumnWriter ( ref mut typed) = column_writer. untyped( ) {
1358
+ if let ColumnWriter :: Int32ColumnWriter ( typed) = column_writer. untyped( ) {
1359
1359
typed. write_batch( & vals[ ..] , Some ( & definition_levels[ ..] ) , None ) ?;
1360
1360
} else {
1361
1361
panic!( "Schema and struct disagree on type for {}" , stringify!{ maybe_happened } )
@@ -1409,7 +1409,7 @@ mod test {
1409
1409
assert_eq ! ( when. writer_snippet( ) . to_string( ) , ( quote!{
1410
1410
{
1411
1411
let vals : Vec <_> = records. iter( ) . map( |rec| rec. unique_id. as_bytes( ) . to_vec( ) . into( ) ) . collect( ) ;
1412
- if let ColumnWriter :: FixedLenByteArrayColumnWriter ( ref mut typed) = column_writer. untyped( ) {
1412
+ if let ColumnWriter :: FixedLenByteArrayColumnWriter ( typed) = column_writer. untyped( ) {
1413
1413
typed. write_batch( & vals[ ..] , None , None ) ?;
1414
1414
} else {
1415
1415
panic!( "Schema and struct disagree on type for {}" , stringify!{ unique_id } )
@@ -1422,14 +1422,14 @@ mod test {
1422
1422
{
1423
1423
let definition_levels : Vec <i16 > = self . iter( ) . map( |rec| if rec. maybe_unique_id. is_some( ) { 1 } else { 0 } ) . collect( ) ;
1424
1424
let vals : Vec <_> = records. iter( ) . filter_map( |rec| {
1425
- if let Some ( ref inner) = rec. maybe_unique_id {
1425
+ if let Some ( inner) = & rec. maybe_unique_id {
1426
1426
Some ( ( & inner. to_string( ) [ ..] ) . into( ) )
1427
1427
} else {
1428
1428
None
1429
1429
}
1430
1430
} ) . collect( ) ;
1431
1431
1432
- if let ColumnWriter :: FixedLenByteArrayColumnWriter ( ref mut typed) = column_writer. untyped( ) {
1432
+ if let ColumnWriter :: FixedLenByteArrayColumnWriter ( typed) = column_writer. untyped( ) {
1433
1433
typed. write_batch( & vals[ ..] , Some ( & definition_levels[ ..] ) , None ) ?;
1434
1434
} else {
1435
1435
panic!( "Schema and struct disagree on type for {}" , stringify!{ maybe_unique_id } )
0 commit comments