Open
Description
When diffing an enum like:
#[derive(SerdeDiff, Serialize, Deserialize, Debug, PartialEq, Clone)]
enum Value {
Str(String),
Int(i32),
}
Let's say we have the diff Value::Str("A") -> Value::Str("B")
.
The diff implementation will produce the following sequence of commands:
[{"Enter":{"EnumVariant":"Str"}},{"Enter":{"FieldIndex":0}},{"Value":"B"},"Exit"]
However, the apply implementation does not consume the final Exit
command, causing the rest of the command stream to get out of sync.
This is because of this code:
serde-diff/serde-diff-derive/src/serde_diff/mod.rs
Lines 362 to 379 in e461da4
Specifically it's because next_path_element
is only called once, instead of being called until it finds an Exit
command. It makes sense to only call it once because an enum can only have one variant, but since the variant still counts as a path segment, an additional Exit should be consumed.
Metadata
Metadata
Assignees
Labels
No labels