11use crate as serde_diff;
22use crate :: { Apply , Diff , SerdeDiff } ;
33use serde:: { Deserialize , Serialize } ;
4+ use std:: collections:: HashMap ;
45use std:: fmt:: Debug ;
6+ use std:: iter:: FromIterator ;
57
68#[ derive( SerdeDiff , Serialize , Deserialize , PartialEq , Debug , Copy , Clone ) ]
79struct TestStruct {
@@ -15,6 +17,9 @@ fn roundtrip<T: SerdeDiff + Serialize + for<'a> Deserialize<'a> + PartialEq + De
1517) {
1618 let diff = Diff :: serializable ( & old, & new) ;
1719 let json_diff = serde_json:: to_string ( & diff) . unwrap ( ) ;
20+
21+ println ! ( "{}" , json_diff) ;
22+
1823 let mut deserializer = serde_json:: Deserializer :: from_str ( & json_diff) ;
1924 let mut target = old. clone ( ) ;
2025 Apply :: apply ( & mut deserializer, & mut target) . unwrap ( ) ;
@@ -59,6 +64,18 @@ fn test_option() {
5964 Some ( TestStruct { a : 52 , b : 32. } ) ,
6065 Some ( TestStruct { a : 42 , b : 12. } ) ,
6166 ) ;
67+ roundtrip (
68+ HashMap :: from_iter ( [
69+ ( 1 , TestStruct { a : 1 , b : 1. } ) ,
70+ ( 2 , TestStruct { a : 2 , b : 2. } ) ,
71+ ( 3 , TestStruct { a : 3 , b : 3. } ) ,
72+ ] ) ,
73+ HashMap :: from_iter ( [
74+ ( 1 , TestStruct { a : 1 , b : 1. } ) ,
75+ ( 3 , TestStruct { a : 4 , b : 4. } ) ,
76+ ( 4 , TestStruct { a : 1 , b : 1. } ) ,
77+ ] ) ,
78+ ) ;
6279
6380 partial (
6481 Some ( TestStruct { a : 5 , b : 2. } ) ,
0 commit comments