pub fn apply<C, I>(target: &mut C, delta: SeqDelta<I>)where
C: IntoIterator<Item = I> + FromIterator<I>,Expand description
Applies an edit script to target in place.
Because splice positions are old-coordinates and monotonically increasing, this walks the old sequence once and rebuilds it; no random access, and no index arithmetic that could drift as edits land.
A SeqDelta produced by diff always upholds the sorted,
non-overlapping invariant. One that was hand-built or arrived over a wire
might not, so out-of-order or overlong splices are clamped rather than
allowed to panic; the result in that case is unspecified but the call
still returns.
use delta_struct::seq::{apply, diff};
let delta = diff(vec![1, 2, 3, 4], vec![1, 9, 3, 4]);
let mut target = vec![1, 2, 3, 4];
apply(&mut target, delta);
assert_eq!(target, vec![1, 9, 3, 4]);