pub enum ArrayMergeStrategy {
Replace,
Append,
Prepend,
Index,
Unique,
}Expand description
Strategy for merging arrays.
Defines how arrays should be combined when both base and overlay contain values at the same path.
§Examples
use cfgmatic_merge::{Merge, MergeBehavior, ArrayMergeStrategy, MergeOptions};
use serde_json::json;
let base = json!([1, 2]);
let overlay = json!([3, 4]);
// Append: [1, 2, 3, 4]
let opts = MergeOptions::new()
.behavior(MergeBehavior::Deep)
.array_strategy(ArrayMergeStrategy::Append);Variants§
Replace
Replace array entirely with overlay.
This is the default behavior.
Append
Append overlay elements after base elements.
Results in [base..., overlay...].
Prepend
Prepend overlay elements before base elements.
Results in [overlay..., base...].
Index
Merge by index (element-wise).
Requires both arrays to have the same length.
Each element at index i in the result comes from overlay.
§Errors
Returns MergeError::InvalidValue if array lengths differ.
Unique
Deduplicate and merge all elements.
Preserves order of first occurrence. Null values are skipped.
Trait Implementations§
Source§impl Clone for ArrayMergeStrategy
impl Clone for ArrayMergeStrategy
Source§fn clone(&self) -> ArrayMergeStrategy
fn clone(&self) -> ArrayMergeStrategy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ArrayMergeStrategy
impl Debug for ArrayMergeStrategy
Source§impl Default for ArrayMergeStrategy
impl Default for ArrayMergeStrategy
Source§fn default() -> ArrayMergeStrategy
fn default() -> ArrayMergeStrategy
Returns the “default value” for a type. Read more
Source§impl PartialEq for ArrayMergeStrategy
impl PartialEq for ArrayMergeStrategy
impl Copy for ArrayMergeStrategy
impl Eq for ArrayMergeStrategy
impl StructuralPartialEq for ArrayMergeStrategy
Auto Trait Implementations§
impl Freeze for ArrayMergeStrategy
impl RefUnwindSafe for ArrayMergeStrategy
impl Send for ArrayMergeStrategy
impl Sync for ArrayMergeStrategy
impl Unpin for ArrayMergeStrategy
impl UnsafeUnpin for ArrayMergeStrategy
impl UnwindSafe for ArrayMergeStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more