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
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,10 +50,11 @@ For more examples take a look at [integration tests](/tests)
50
50
## Derive macro attributes
51
51
-`#[difference(skip)]` - Do not consider this field when creating a diff
52
52
-`#[difference(recurse)]` - Generate a StructDiff for this field when creating a diff
53
-
-`#[difference(collection_strategy = {})]`
54
-
-`"unordered_array_like"` - Generates a changeset for array-like collections of items which implement `Hash + Eq`, rather than cloning the entire list. (currently works for `Vec`, `BTreeSet`, `LinkedList`, and `HashSet`)
55
-
-`"unordered_map_like"` - Generates a changeset for map-like collections for which the key implements `Hash + Eq`, rather than cloning the entire map. (currently works for `HashMap` and `BTreeMap`)
56
-
-`#[difference(map_equality = {})]` - Used with `unordered_map_like`, specifies whether the equality check should consider keys only, or both keys and values
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`
57
58
-`"key_only"` - only replace a key-value pair for which the key has changed
58
59
-`"key_and_value"` - replace a key-value pair if either the key or value has changed
59
60
-`#[difference(setters)]` - Generate setters for all fields in the struct (used on struct)
let generic_names = field.ty.wraps.as_ref().map(|x| x.iter().map(|y| y.full().clone()).collect::<Vec<_>>()).expect("Missing types for map creation").join(",");
let generic_ref_names = field.ty.wraps.as_ref().map(|x| x.iter().map(|y| y.full()).collect::<Vec<_>>()).expect("Missing types for map creation").join(", &'__diff_target ");
609
+
l!(diff_enum_body," {}(structdiff::collections::ordered_array_like::OrderedArrayLikeDiffOwned<{}>),", field_name, field.ty.wraps.as_ref().expect("Using collection strategy on a non-collection")[0].full());
l!(setters_body,"\n\tlet ret = structdiff::collections::ordered_array_like::levenshtein(&value, &self.{}).map(|x| <Self as StructDiff>::Diff::{}(x.into()));", field_name, field_name);
l!(setters_body,"\n\tlet ret = structdiff::collections::ordered_array_like::levenshtein(&value, &self.{}).map(|x| <Self as StructDiff>::Diff::{}(x.into()));", field_name, field_name);
let generic_ref_names = field.ty.wraps.as_ref().map(|x| x.iter().map(|y| y.full()).collect::<Vec<_>>()).expect("Missing types for map creation").join(", &'__diff_target ");
604
677
l!(diff_enum_body," {}(structdiff::collections::unordered_array_like::UnorderedArrayLikeDiff<{}>),", field_name, field.ty.wraps.as_ref().expect("Using collection strategy on a non-collection")[0].full());
l!(setters_body,"\n\tstructdiff::collections::unordered_array_like::unordered_hashcmp(self.{}.iter(), value.iter()).map(|x| <Self as StructDiff>::Diff::{}(x.into()))", field_name, field_name);
727
+
l!(setters_body,"\n\tlet ret = structdiff::collections::unordered_array_like::unordered_hashcmp(self.{}.iter(), value.iter()).map(|x| <Self as StructDiff>::Diff::{}(x.into()));", field_name, field_name);
l!(setters_body,"\n\tstructdiff::collections::unordered_array_like::unordered_hashcmp(self.{}.iter(), value.iter()).map(|x| <Self as StructDiff>::Diff::{}(x.into()))", field_name, field_name);
735
+
l!(setters_body,"\n\tlet ret = structdiff::collections::unordered_array_like::unordered_hashcmp(self.{}.iter(), value.iter()).map(|x| <Self as StructDiff>::Diff::{}(x.into()));", field_name, field_name);
0 commit comments