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:
§struct
s
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
new
is aNone
,current
is unchanged. -
If
new
is aSome(new_inner)
:-
If
current
is aNone
,current
becomesSome(new_inner)
. -
If
current
is aSome(current_inner)
,current_inner
is 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
.