pub fn to_position(&self, offset: usize) -> Position {
        if !self.cache_offset2position.read().contains_key(&offset) {
            let line = self
                .lines
                .binary_search_by(|&(line_start_offset, line_len)| {
                    if offset < line_start_offset {
                        std::cmp::Ordering::Greater
                    } else if offset > line_start_offset + line_len {
                        std::cmp::Ordering::Less
                    } else {
                        std::cmp::Ordering::Equal
                    }
                })
                .expect("Offset not found!");
            let (line_start_offset, _) = self.lines[line];
            let position = WrappedPosition::new(line, offset - line_start_offset);
            self.cache_offset2position.write().insert(offset, position);
        }

        (*self.cache_offset2position.read().get(&offset).unwrap()).into()
    }
/// Returns the line/column position corresponding to a byte offset in the source.
Returns the line/column position corresponding to a byte offset in the source.
Returns the line / column position corresponding to a byte offset in the source .
pub fn to_position(&self, offset: usize) -> Position {
        if !self.cache_offset2position.read().contains_key(&offset) {
            let line = self
                .lines
                .binary_search_by(|&(line_start_offset, line_len)| {
                    if offset < line_start_offset {
                        std::cmp::Ordering::Greater
                    } else if offset > line_start_offset + line_len {
                        std::cmp::Ordering::Less
                    } else {
                        std::cmp::Ordering::Equal
                    }
                })
                .expect("Offset not found!");
            let (line_start_offset, _) = self.lines[line];
            let position = WrappedPosition::new(line, offset - line_start_offset);
            self.cache_offset2position.write().insert(offset, position);
        }
        (*self.cache_offset2position.read().get(&offset).unwrap()).into()
    }
pub fn to_position ( & self , offset : usize ) -> Position { if ! self . cache_offset2position . read ( ) . contains_key ( & offset ) { let line = self . lines . binary_search_by ( | & ( line_start_offset , line_len ) | { if offset < line_start_offset { std :: cmp :: Ordering :: Greater } else if offset > line_start_offset + line_len { std :: cmp :: Ordering :: Less } else { std :: cmp :: Ordering :: Equal } } ) . expect ( " " ) ; let ( line_start_offset , _ ) = self . lines [ line ] ; let position = WrappedPosition :: new ( line , offset - line_start_offset ) ; self . cache_offset2position . write ( ) . insert ( offset , position ) ; } ( * self . cache_offset2position . read ( ) . get ( & offset ) . unwrap ( ) ) . into ( ) }
Returns the line/column position corresponding to a byte offset in the source.
Returns the line / column position corresponding to a byte offset in the source .
&self
offset
usize
&self
offset
usize