Skip to main content

splice

Function splice 

Source
pub fn splice(source: &str, edits: &[AppliedEdit]) -> String
Expand description

Apply edits to source by byte-splice. Edits are spliced in reverse start order so earlier offsets stay valid; whitespace outside each span is preserved verbatim.

Edits MUST be non-overlapping — the engine resolves overlaps up front (see engine::dedupe_overlapping) by keeping the outermost match. This function is a defensive backstop: an out-of-range, mis-aligned, or overlapping span is skipped rather than allowed to panic replace_range, so a buggy rule can never corrupt a file by splicing a stale offset.