fn slice(&self, start: Location, end: Location) -> Option<&'input str> {
        let start = start.absolute - self.start_index.to_usize();
        let end = end.absolute - self.start_index.to_usize();

        // Our indexes are in characters as we are iterating over codepoints
        // string indexes however are in bytes and might lead to either
        // invalid regions or even invalid strings
        // That is terrible, what are you thinking rust!
        // But at lease we can work around it using `indices`
        let start = self.input.char_indices().nth(start)?.0;
        let end = self.input.char_indices().nth(end)?.0;
        self.input.get(start..end)
    }
/// Return a slice of the source string
Return a slice of the source string
Return a slice of the source string
fn slice(&self, start: Location, end: Location) -> Option<&'input str> {
        let start = start.absolute - self.start_index.to_usize();
        let end = end.absolute - self.start_index.to_usize();
        // Our indexes are in characters as we are iterating over codepoints
        // string indexes however are in bytes and might lead to either
        // invalid regions or even invalid strings
        // That is terrible, what are you thinking rust!
        // But at lease we can work around it using `indices`
        let start = self.input.char_indices().nth(start)?.0;
        let end = self.input.char_indices().nth(end)?.0;
        self.input.get(start..end)
    }
fn slice ( & self , start : Location , end : Location ) -> Option < & ' input str > { let start = start . absolute - self . start_index . to_usize ( ) ; let end = end . absolute - self . start_index . to_usize ( ) ; // Our indexes are in characters as we are iterating over codepoints // string indexes however are in bytes and might lead to either // invalid regions or even invalid strings // That is terrible, what are you thinking rust! // But at lease we can work around it using `indices` let start = self . input . char_indices ( ) . nth ( start ) ? . 0 ; let end = self . input . char_indices ( ) . nth ( end ) ? . 0 ; self . input . get ( start .. end ) }
Return a slice of the source string
Return a slice of the source string
&self
start
Location
end
Location
&self
start
Location
end
Location