You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-13Lines changed: 16 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,19 +48,22 @@ assert_ne!(diffed, second);
48
48
For more examples take a look at [integration tests](/tests)
49
49
50
50
## Derive macro attributes
51
-
-`#[difference(skip)]` - Do not consider this field when creating a diff
52
-
-`#[difference(recurse)]` - Generate a StructDiff for this field when creating a diff
53
-
-`#[difference(collection_strategy = {})]`
54
-
-`"ordered_array_like"` - Generates a minimal changeset for ordered, array-like collections of items which implement `PartialEq`. (uses levenshtein difference)
55
-
-`"unordered_array_like"` - Generates a minimal changeset for unordered, array-like collections of items which implement `Hash + Eq`.
56
-
-`"unordered_map_like"` - Generates a minimal changeset for unordered, map-like collections for which the key implements `Hash + Eq`.
57
-
-`#[difference(map_equality = {})]` - Used with `unordered_map_like`
58
-
-`"key_only"` - only replace a key-value pair for which the key has changed
59
-
-`"key_and_value"` - replace a key-value pair if either the key or value has changed
60
-
-`#[difference(setters)]` - Generate setters for all fields in the struct (used on struct)
61
-
- Example: for the `field1` of the `Example` struct used above, a function with the signature `set_field1_with_diff(&mut self, value: Option<usize>) -> Option<<Self as StructDiff>::Diff>` will be generated. Useful when a single field will be changed in a struct with many fields, as it saves the comparison of all other fields.
62
-
-`#[difference(setter)]` - Generate setters for this struct field (used on field)
63
-
-`#[difference(setter_name = {})]` - Use this name instead of the default value when generating a setter for this field (used on field)
51
+
- Field level
52
+
-`#[difference(skip)]` - Do not consider this field when creating a diff
53
+
-`#[difference(recurse)]` - Generate a StructDiff for this field when creating a diff
54
+
-`#[difference(collection_strategy = {})]`
55
+
-`"ordered_array_like"` - Generates a minimal changeset for ordered, array-like collections of items which implement `PartialEq`. (uses levenshtein difference)
56
+
-`"unordered_array_like"` - Generates a minimal changeset for unordered, array-like collections of items which implement `Hash + Eq`.
57
+
-`"unordered_map_like"` - Generates a minimal changeset for unordered, map-like collections for which the key implements `Hash + Eq`.
58
+
-`#[difference(map_equality = {})]` - Used with `unordered_map_like`
59
+
-`"key_only"` - only replace a key-value pair for which the key has changed
60
+
-`"key_and_value"` - replace a key-value pair if either the key or value has changed
61
+
-`#[difference(setter)]` - Generate setters for this struct field
62
+
-`#[difference(setter_name = {})]` - Use this name instead of the default value when generating a setter for this field (used on field)
63
+
- Struct Level
64
+
-`#[difference(setters)]` - Generate setters for all fields in the struct
65
+
- Example: for the `field1` of the `Example` struct used above, a function with the signature `set_field1_with_diff(&mut self, value: Option<usize>) -> Option<<Self as StructDiff>::Diff>` will be generated. Useful when a single field will be changed in a struct with many fields, as it saves the comparison of all other fields.
66
+
-`#[difference(expose)]`/`#[difference(expose = "MyDiffTypeName")]` - expose the generated difference type (optionally, with the specified name)
64
67
65
68
## Optional features
66
69
-[`nanoserde`, `serde`] - Serialization of `Difference` derived associated types. Allows diffs to easily be sent over network.
0 commit comments