Struct rustpython_parser::source_code::SourceCode
pub struct SourceCode<'src, 'index> { /* private fields */ }
Expand description
Gives access to the source code of a file and allows mapping between TextSize
and SourceLocation
.
Implementations§
§impl<'src, 'index> SourceCode<'src, 'index>
impl<'src, 'index> SourceCode<'src, 'index>
pub fn new( content: &'src str, index: &'index LineIndex ) -> SourceCode<'src, 'index>
pub fn source_location(&self, offset: TextSize) -> SourceLocation
pub fn source_location(&self, offset: TextSize) -> SourceLocation
Computes the one indexed row and column numbers for offset
.
pub fn line_index(&self, offset: TextSize) -> OneIndexed
pub fn line_start(&self, line: OneIndexed) -> TextSize
pub fn line_end(&self, line: OneIndexed) -> TextSize
pub fn line_range(&self, line: OneIndexed) -> TextRange
pub fn line_text(&self, index: OneIndexed) -> &'src str
pub fn line_text(&self, index: OneIndexed) -> &'src str
Returns the source text of the line with the given index
pub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Returns the number of lines
Trait Implementations§
§impl<'src, 'index> Debug for SourceCode<'src, 'index>
impl<'src, 'index> Debug for SourceCode<'src, 'index>
§impl PartialEq<SourceCode<'_, '_>> for SourceCode<'_, '_>
impl PartialEq<SourceCode<'_, '_>> for SourceCode<'_, '_>
§fn eq(&self, other: &SourceCode<'_, '_>) -> bool
fn eq(&self, other: &SourceCode<'_, '_>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for SourceCode<'_, '_>
Auto Trait Implementations§
impl<'src, 'index> RefUnwindSafe for SourceCode<'src, 'index>
impl<'src, 'index> Send for SourceCode<'src, 'index>
impl<'src, 'index> Sync for SourceCode<'src, 'index>
impl<'src, 'index> Unpin for SourceCode<'src, 'index>
impl<'src, 'index> UnwindSafe for SourceCode<'src, 'index>
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