Skip to main content

splice_range

Function splice_range 

Source
pub fn splice_range(
    runs: &mut Vec<FormatRun>,
    range: Range<u32>,
    replacement: Vec<FormatRun>,
)
Expand description

Replace the runs covering range with replacement, preserving the invariants. Runs that straddle the range boundary are clipped on either side; runs fully contained are removed.

The replacement byte ranges must lie within range and themselves be well-formed (sorted, non-overlapping). The function does NOT shift bytes after range.end — callers wanting to splice in a different-length text must call shift_after first or after, depending on whether the text length is changing.