pub struct SourceFile { /* private fields */ }Expand description
A single source file, with a precomputed index of where each line starts.
Implementations§
Source§impl SourceFile
impl SourceFile
pub fn name(&self) -> &str
pub fn text(&self) -> &str
pub fn line_count(&self) -> u32
Sourcepub fn location(&self, offset: u32) -> Location
pub fn location(&self, offset: u32) -> Location
Resolves a byte offset to a one based line and column.
Offsets past the end of the file clamp to the last position, so a diagnostic about unexpected end of input still renders somewhere sane.
Sourcepub fn line_text(&self, line: u32) -> &str
pub fn line_text(&self, line: u32) -> &str
The text of a one based line, without its trailing newline.
pub fn slice(&self, span: Span) -> &str
Auto Trait Implementations§
impl Freeze for SourceFile
impl RefUnwindSafe for SourceFile
impl Send for SourceFile
impl Sync for SourceFile
impl Unpin for SourceFile
impl UnsafeUnpin for SourceFile
impl UnwindSafe for SourceFile
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