-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Here is the example:
#[derive(struct_patch::Patch, Debug, PartialEq)]
struct Foo {
maybe_name: Option<String>,
}
let mut foo = Foo { maybe_name: None };
let mut patch = Foo::new_empty_patch();
patch.maybe_name = Some(Some("Should be kept".to_owned()));
foo.apply(patch);
assert_eq!(foo, Foo {
maybe_name: Some("Should be kept".to_owned())
});
let mut patch = Foo::new_empty_patch();
patch.maybe_name = Some(Some("Being overwritten".to_owned()));
foo.apply(patch);
// The content is overwritten
assert_ne!(foo, Foo {
maybe_name: Some("Should be kept".to_owned())
});
I hope there is something like
#[derive(struct_patch::Patch)]
struct Foo {
#[patch(skip_if(Option::is_some))]
maybe_name: Option<String>,
}
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request