Skip to content
This repository was archived by the owner on Aug 15, 2021. It is now read-only.

Commit 3854fc1

Browse files
committed
Fix roundtrip of f64 field.
1 parent 848b811 commit 3854fc1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/de.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,11 @@ where
732732
0xf8 => Err(self.error(ErrorCode::UnassignedCode)),
733733
0xf9 => {
734734
let value = self.parse_f16()?;
735-
visitor.visit_f32(value)
735+
visitor.visit_f64(value as f64)
736736
}
737737
0xfa => {
738738
let value = self.parse_f32()?;
739-
visitor.visit_f32(value)
739+
visitor.visit_f64(value as f64)
740740
}
741741
0xfb => {
742742
let value = self.parse_f64()?;

tests/roundtrip.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct MyStuff {
1414
enum MyStuffType {
1515
ver1 {
1616
x: f64,
17+
y: f32,
1718
},
1819
ver2
1920
}
@@ -23,7 +24,8 @@ enum MyStuffType {
2324
fn test_roundtrip() {
2425
let stuff1 = MyStuff {
2526
data: MyStuffType::ver1 {
26-
x: 2.5
27+
x: 2.5,
28+
y: 2.5,
2729
}
2830
};
2931
let data_bytes = serde_cbor::to_vec(&stuff1).unwrap();

0 commit comments

Comments
 (0)