pub trait Merge {
// Required method
fn merge(&self, other: &Self) -> Result<Self, Box<dyn Error>>
where Self: Sized;
}
Expand description
Trait for types that support merging two values and producing a new value with the result of the merge. The input values are left unchanged.
Required Methods§
Implementations on Foreign Types§
Source§impl<T: Clone + Merge> Merge for Option<T>
Implementation of merge for the Option type. The merge is defined with the following
logic chart:
impl<T: Clone + Merge> Merge for Option<T>
Implementation of merge for the Option type. The merge is defined with the following logic chart:
Target | Other | Result |
---|---|---|
None | None | None |
Some(a) | None | Some(a) |
None | Some(b) | Some(b) |
Some(a) | Some(b) | Some(a.merge(b)) |
Two Option instances can only merge if their containing data elements also support merging.
Source§impl<T: Clone + Merge, E: Clone + Merge> Merge for Result<T, E>
Implementation of merge for the Result type. The merge strategy used is right-bias
towards the error case. If the target or right hand side is an Err instance, the
result will contain that Err value. When both values are Ok, then the result will
be an Ok containing the result of merging the inner values.
impl<T: Clone + Merge, E: Clone + Merge> Merge for Result<T, E>
Implementation of merge for the Result type. The merge strategy used is right-bias towards the error case. If the target or right hand side is an Err instance, the result will contain that Err value. When both values are Ok, then the result will be an Ok containing the result of merging the inner values.