Skip to main content

slice_source_location

Function slice_source_location 

Source
pub fn slice_source_location(
    src: &SourceLocation,
    start: usize,
    length: usize,
) -> SourceLocation
Expand description

Slice the source location.

§Arguments

  • src - The source location
  • start - The start index
  • length - The length of the sliced source

§Returns

The sliced source location.

§Example

let src = SourceLocation { start: Some(1), length: Some(10), index: Some(0) };
let sliced = slice_source_location(&src, 1, 3);
assert_eq!(sliced.start, Some(2));
assert_eq!(sliced.length, Some(3));
assert_eq!(sliced.index, Some(0));