Trait Merge

Source
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§

Source

fn merge(&self, other: &Self) -> Result<Self, Box<dyn Error>>
where Self: Sized,

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:

TargetOtherResult
NoneNoneNone
Some(a)NoneSome(a)
NoneSome(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§

fn merge(&self, rhs: &Self) -> Result<Self, Box<dyn Error>>
where Self: Sized,

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.

Source§

fn merge(&self, rhs: &Self) -> Result<Self, Box<dyn Error>>
where Self: Sized,

Implementors§