pub struct SourceLocation { /* private fields */ }Expand description
Provides fast conversion from byte offsets to line/column positions
Implementations§
Source§impl SourceLocation
impl SourceLocation
Sourcepub fn byte_to_position(&self, byte_offset: usize) -> Position
pub fn byte_to_position(&self, byte_offset: usize) -> Position
Convert a byte offset to a line/column position
Sourcepub fn byte_range_to_ast_range(&self, range: &ByteRange<usize>) -> Range
pub fn byte_range_to_ast_range(&self, range: &ByteRange<usize>) -> Range
Convert a byte range to a location
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Get the total number of lines in the source
Sourcepub fn line_start(&self, line: usize) -> Option<usize>
pub fn line_start(&self, line: usize) -> Option<usize>
Get the byte offset for the start of a line
Auto Trait Implementations§
impl Freeze for SourceLocation
impl RefUnwindSafe for SourceLocation
impl Send for SourceLocation
impl Sync for SourceLocation
impl Unpin for SourceLocation
impl UnsafeUnpin for SourceLocation
impl UnwindSafe for SourceLocation
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more