Trait k8s_openapi::DeepMerge
source · pub trait DeepMerge {
// Required method
fn merge_from(&mut self, other: Self);
}Expand description
A trait applies to types that support deep merging.
current.merge_from(new) behaves in the following ways:
§structs
Structs are merged by individually merging each of their fields. For example, given:
struct S {
a: i32,
b: String,
}… the expected impl of DeepMerge for S would be:
impl DeepMerge for S {
fn merge_from(&mut self, other: Self) {
self.a.merge_from(other.a);
self.b.merge_from(other.b);
}
}The structs in the k8s-openapi crate behave this way. If you are implementing this trait for your own types, it is recommended to impl it in the same way.
§Option
-
If
newis aNone,currentis unchanged. -
If
newis aSome(new_inner):-
If
currentis aNone,currentbecomesSome(new_inner). -
If
currentis aSome(current_inner),current_inneris merged withnew_inner.
-
§Vec
Use an explicit merge strategy.
§BTreeMap
Use an explicit merge strategy.
§serde_json::Value
serde_json::Value is merged using the JSON merge algorithm (RFC 7396).
§Other types
self is just replaced by other.
Required Methods§
sourcefn merge_from(&mut self, other: Self)
fn merge_from(&mut self, other: Self)
Merge other into self.