pub struct Position { /* private fields */ }
Expand description
Represents a position in the source code.
The line and column are zero-based, character offsets.
It is different from tree-sitter’s position which is zero-based byte
offsets.
Note, accessing column
is O(n) operation.
Implementations§
Source§impl Position
impl Position
pub fn new(line: usize, byte_column: usize, byte_offset: usize) -> Self
pub fn line(&self) -> usize
Sourcepub fn column<D: Doc>(&self, node: &Node<'_, D>) -> usize
pub fn column<D: Doc>(&self, node: &Node<'_, D>) -> usize
Returns the column in terms of characters. Note: node does not have to be a node of matching position.
pub fn byte_point(&self) -> (usize, usize)
Trait Implementations§
impl Copy for Position
impl Eq for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Freeze for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnwindSafe for Position
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more