Trait k8s_openapi::DeepMerge
source · pub trait DeepMerge {
fn merge_from(&mut self, other: Self);
}Expand description
A trait applies to types that support deep merging.
a.merge_from(b) 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
bis aNone,ais unchanged. -
If
bis aSome(b_inner):-
If
ais aSome(a_inner),a_inneris merged withb_inner. -
If
ais aNone,abecomesSome(b_inner).
-
Vec
The elements of b are appended to a.
BTreeMap
For each key k in b:
-
If
acontains the keyktoo, the value inais merged with the value inb. -
If
adoes not contain the keyk, the value inbis inserted intoa.
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.