pub struct Position {
pub line: u32,
pub character: u32,
}Expand description
A struct representing a specific point in a document. Lines and characters are zero-based.
Fields§
§line: u32The line in which this position points to, starting from 0.
character: u32The character in the line that this position points to,
starting from 0.
Implementations§
Source§impl Position
impl Position
Sourcepub fn offset(&mut self, lines: i32, characters: i32)
pub fn offset(&mut self, lines: i32, characters: i32)
Offsets the current position by lines and characters. If you’re adding both
lines and characters, making sure to set characters to 0 before calling
this function to ensure correct results.
Sourcepub fn set_character(&mut self, character: u32)
pub fn set_character(&mut self, character: u32)
Sets character to a specific value.
Sourcepub fn is_in_bounds(self, start: Position, end: Position) -> bool
pub fn is_in_bounds(self, start: Position, end: Position) -> bool
Checks whether or not this position is between the 2 passed positions.
Trait Implementations§
Source§impl Ord for Position
impl Ord for Position
Source§impl PartialOrd for Position
impl PartialOrd for Position
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