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
sourceimpl<T: Clone> Merge for Vec<T>
impl<T: Clone> Merge for Vec<T>
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.
sourceimpl<T: Clone + Eq + Hash> Merge for HashSet<T>
impl<T: Clone + Eq + Hash> Merge for HashSet<T>
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.
sourceimpl<T: Clone + Eq + Ord> Merge for BTreeSet<T>
impl<T: Clone + Eq + Ord> Merge for BTreeSet<T>
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.
sourceimpl<T: Clone> Merge for LinkedList<T>
impl<T: Clone> Merge for LinkedList<T>
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.
sourceimpl<T: Clone + Merge> Merge for Option<T>
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.
sourceimpl<T: Clone + Merge, E: Clone + Merge> Merge for Result<T, E>
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.