Skip to main content

try_parser_span_to_text_range

Function try_parser_span_to_text_range 

Source
pub fn try_parser_span_to_text_range(
    source: &str,
    span: Span,
) -> Result<TextRange, ParserSpanToTextRangeError>
Expand description

Try to convert a parser span into a text-size byte range.

This is the fallible API and should be used for spans sourced outside SourceFile where invalid offsets are possible; offsets must be valid UTF-8 character boundaries.

ยงErrors

Returns ParserSpanToTextRangeError when span is out of bounds, inverted, not on a UTF-8 boundary, or cannot fit in TextSize.