serde-diff
serde-diff copied to clipboard
Utility for comparing two structs and re-applying the differences to other structs
Based on #33
- Fixes #32 - Changes tuples to always use field indexes instead of stringifying the index - Makes the "FieldPathMode" option work for fields as well (it previously did nothing)
```rust let x = QueryResult::Test(1); let y = QueryResult::Test(2); let diff = serde_diff::Config::new() .with_field_path_mode(FieldPathMode::Index) .serializable_diff(&x, &y); let z = ron::to_string(&diff).unwrap(); println!("{}", z); ``` Expected output: ``` [Enter(EnumVariantIndex(1)),Enter(FieldIndex(0)),Value(2),Exit] ``` Actual output:...
It should at least be documented that it will always return false until the diff is serialized to a serializer.
#### Example to reproduce the issue ``` use serde::{Deserialize, Serialize}; use serde_diff::{Apply, Diff, SerdeDiff}; #[derive(SerdeDiff, Serialize, Deserialize, PartialEq, Debug, Clone)] struct TestStruct { a: Option, } fn main() { let...
`min_const_generics` is in stable now, so we can use it for the array impl: https://github.com/amethyst/serde-diff/blob/e461da41c9339af3ecadf9f4aa61ae91c1f79e97/src/implementation.rs#L17 Other crates have also switched to const generics for array impls (such as [`arrayvec`](https://github.com/bluss/arrayvec/blob/master/CHANGELOG.md#060)).
The code for `Option` https://github.com/amethyst/serde-diff/blob/e461da41c9339af3ecadf9f4aa61ae91c1f79e97/src/implementation.rs#L315-L356 would be more readable if written like the code for arrays https://github.com/amethyst/serde-diff/blob/e461da41c9339af3ecadf9f4aa61ae91c1f79e97/src/implementation.rs#L25-L37
`SerdeDiff` derive macro uses generic parameter `A`. It might be better to rename it to `__A` or `__FirstParam` or something like that, to free up this name for end user?
The error occurs on the line `Apply::apply`. I guess the deserializer, which takes `serde_json::to_string(&Diff::serialize...)` gets wrong json as input. I've uploaded the json and small code to https://github.com/SirWindfield/serde-diff-error. The error...