Skip to main content

replace_at_span

Function replace_at_span 

Source
pub fn replace_at_span(
    content: &[u8],
    span: &ReferenceFact,
    new_name: &[u8],
) -> Result<Vec<u8>>
Expand description

Perform byte-accurate replacement at a specific span.

This function replaces the content between byte_start and byte_end with new_name, preserving all other content exactly as-is.

§Arguments

  • content - File content as bytes
  • span - ReferenceFact with byte_start/byte_end
  • new_name - Replacement name (as bytes)

§Returns

Modified content with replacement applied

§Errors

Returns InvalidSpan if byte_start/byte_end are out of bounds or if the span crosses UTF-8 character boundaries.