We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 99f8582 commit 06253c2Copy full SHA for 06253c2
src/test.rs
@@ -349,3 +349,17 @@ fn readme_bencode_example() {
349
let list_serialize: Vec<u8> = ser.into();
350
assert_eq!(String::from_utf8(list_serialize).unwrap(), "l3:one3:two5:threei4ee");
351
}
352
+
353
+#[test]
354
+fn struct_none_vals() {
355
+ #[derive(Serialize)]
356
+ struct Fake {
357
+ a: Option<i32>,
358
+ b: Option<i32>
359
+ };
360
+ let f = Fake { a: None, b: Some(1) };
361
+ let mut ser = Encoder::new();
362
+ f.serialize(&mut ser).unwrap();
363
+ let r: Vec<u8> = ser.into();
364
+ assert_eq!(String::from_utf8(r).unwrap(), "d1:bi1ee");
365
+}
0 commit comments