@@ -489,6 +489,19 @@ impl<'a, R: Read> DeserializerState<'a, R> {
489
489
add_property ( instance, & property, value. into ( ) ) ;
490
490
}
491
491
}
492
+ // This branch allows values serialized as Int32 to be converted to Int64 when we expect a Int64
493
+ // Basically, we convert Int32 to Int64 when we expect a Int64 but read a Int32
494
+ // See: #301
495
+ VariantType :: Int64 => {
496
+ let mut values = vec ! [ 0 ; type_info. referents. len( ) ] ;
497
+ chunk. read_interleaved_i32_array ( & mut values) ?;
498
+
499
+ for ( value, referent) in values. into_iter ( ) . zip ( & type_info. referents ) {
500
+ let instance = self . instances_by_ref . get_mut ( referent) . unwrap ( ) ;
501
+ let value_converted = i64:: from ( value) ;
502
+ add_property ( instance, & property, value_converted. into ( ) ) ;
503
+ }
504
+ }
492
505
invalid_type => {
493
506
return Err ( InnerError :: PropTypeMismatch {
494
507
type_name : type_info. type_name . clone ( ) ,
@@ -525,6 +538,19 @@ impl<'a, R: Read> DeserializerState<'a, R> {
525
538
add_property ( instance, & property, value. into ( ) ) ;
526
539
}
527
540
}
541
+ // This branch allows values serialized as Float32 to be converted to Float64 when we expect a Float64
542
+ // Basically, we convert Float32 to Float64 when we expect a Float64 but read a Float32
543
+ // See: #301
544
+ VariantType :: Float32 => {
545
+ let mut values = vec ! [ 0.0 ; type_info. referents. len( ) ] ;
546
+ chunk. read_interleaved_f32_array ( & mut values) ?;
547
+
548
+ for ( value, referent) in values. into_iter ( ) . zip ( & type_info. referents ) {
549
+ let instance = self . instances_by_ref . get_mut ( referent) . unwrap ( ) ;
550
+ let converted_value = f64:: from ( value) ;
551
+ add_property ( instance, & property, converted_value. into ( ) ) ;
552
+ }
553
+ }
528
554
invalid_type => {
529
555
return Err ( InnerError :: PropTypeMismatch {
530
556
type_name : type_info. type_name . clone ( ) ,
0 commit comments