pub trait Merge {
    fn merge(&self, other: &Self) -> Self;
}
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

Implementation of Merge for the Vec type. The resulting Vec contains all of the elements from the target Vec followed by all of the elements from the right hand side Vec.

Implementation of Merge for the HashSet type. The resulting HashSet is the union of elements from the target HashSet and the right hand side HashSet. Order of elements in the merged result may differ based on the hashing algorithm.

Implementation of Merge for the BTreeSet type. The resulting BTreeSet is the union of elements from the target BTreeSet and the right hand side BTreeSet. Elements in the resulting BTreeSet will be their correct order as defined in the BTreeSet type.

Implementation of Merge for LinkedList type. The resulting LinkedList is a new list with all the elements from the target list followed by all of the elements from the right hand side list.

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.

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.

Implementors