pub fn splice(&mut self, span: &Span, replacement: &str) {
    let span = span.adjust_offsets(&self.splice_offsets);

    // determine the splice offset (only used on subsequent splices)
    let prev_len = span.end - span.start;
    let new_len = replacement.len();
    let offset = new_len as isize - prev_len as isize;
    self.splice_offsets.push(
      SpliceOffset { position: span.start, offset }
    );

    // split and rebuild the content with the replacement instead
    let (beginning, rest) = self.content.split_at(span.start);
    let (_, end) = rest.split_at(span.end - span.start);
    self.content = format!("{}{}{}", beginning, replacement, end);
  }
/// Replaces a Span with the given replacement string, mutating the `content`
/// string.
///
/// Sections may be deleted by replacing them with an empty string (`""`).
///
/// Note that spans are always relative to the *original input document*.
/// Span offsets are recalculated at call-time to account for previous calls
/// to `splice(...)` that may have shifted one or both of the span bounds.
Replaces a Span with the given replacement string, mutating the `content`
string.

Sections may be deleted by replacing them with an empty string (`""`).

Note that spans are always relative to the *original input document*.
Span offsets are recalculated at call-time to account for previous calls
to `splice(...)` that may have shifted one or both of the span bounds.
Replaces a Span with the given replacement string mutating the ` content ` string . Sections may be deleted by replacing them with an empty string ( ` " " ` ) . Note that spans are always relative to the * original input document * . Span offsets are recalculated at call - time to account for previous calls to ` splice ( ... ) ` that may have shifted one or both of the span bounds .
pub fn splice(&mut self, span: &Span, replacement: &str) {
    let span = span.adjust_offsets(&self.splice_offsets);
    // determine the splice offset (only used on subsequent splices)
    let prev_len = span.end - span.start;
    let new_len = replacement.len();
    let offset = new_len as isize - prev_len as isize;
    self.splice_offsets.push(
      SpliceOffset { position: span.start, offset }
    );
    // split and rebuild the content with the replacement instead
    let (beginning, rest) = self.content.split_at(span.start);
    let (_, end) = rest.split_at(span.end - span.start);
    self.content = format!("{}{}{}", beginning, replacement, end);
  }
pub fn splice ( & mut self , span : & Span , replacement : & str ) { let span = span . adjust_offsets ( & self . splice_offsets ) ; // determine the splice offset (only used on subsequent splices) let prev_len = span . end - span . start ; let new_len = replacement . len ( ) ; let offset = new_len as isize - prev_len as isize ; self . splice_offsets . push ( SpliceOffset { position : span . start , offset } ) ; // split and rebuild the content with the replacement instead let ( beginning , rest ) = self . content . split_at ( span . start ) ; let ( _ , end ) = rest . split_at ( span . end - span . start ) ; self . content = format ! ( " " beginning replacement end ) ; }
Replaces a Span with the given replacement string, mutating the `content`
string.
Replaces a Span with the given replacement string mutating the ` content ` string .
&mut self
span
&Span
replacement
&str