pub struct Position {
pub line: u32,
pub column: u32,
}Fields§
§line: u321-based line number in the source file.
column: u321-based column number in the source file.
Implementations§
Source§impl Position
impl Position
pub fn new(line: u32, column: u32) -> Self
Sourcepub fn from_byte_index(source: &str, byte_index: usize) -> Self
pub fn from_byte_index(source: &str, byte_index: usize) -> Self
Creates a position for the given byte_index in the given source.
Sourcepub fn from_relative_byte_index(
prev: Self,
prev_byte_index: usize,
source: &str,
byte_index: usize,
) -> Self
pub fn from_relative_byte_index( prev: Self, prev_byte_index: usize, source: &str, byte_index: usize, ) -> Self
Create a position for the given byte_index in the given source,
counting from the given other position. This avoids double work in case
one position lies after another.
Sourcepub fn byte_index(&self, source: &str) -> usize
pub fn byte_index(&self, source: &str) -> usize
Returns the byte index for this Position within the given source.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Position
impl<'de> Deserialize<'de> for Position
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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