pub struct File {
pub span: Span,
/* private fields */
}
Expand description
A CodeMap
’s record of a source file.
Fields§
§span: Span
The span representing the entire file.
Implementations§
source§impl File
impl File
sourcepub fn find_line(&self, pos: Pos) -> usize
pub fn find_line(&self, pos: Pos) -> usize
Gets the line number of a Pos.
The lines are 0-indexed (first line is numbered 0)
§Panics
- If
pos
is not within this file’s span
sourcepub fn find_line_col(&self, pos: Pos) -> LineCol
pub fn find_line_col(&self, pos: Pos) -> LineCol
Gets the line and column of a Pos.
§Panics
- If
pos
is not with this file’s span - If
pos
points to a byte in the middle of a UTF-8 character
sourcepub fn source_slice(&self, span: Span) -> &str
pub fn source_slice(&self, span: Span) -> &str
sourcepub fn line_span(&self, line: usize) -> Span
pub fn line_span(&self, line: usize) -> Span
Gets the span representing a line by line number.
The line number is 0-indexed (first line is numbered 0). The returned span includes the line terminator.
§Panics
- If the line number is out of range
sourcepub fn source_line(&self, line: usize) -> &str
pub fn source_line(&self, line: usize) -> &str
Gets the source text of a line.
The string returned does not include the terminating \r or \n characters.
§Panics
- If the line number is out of range
Trait Implementations§
impl Eq for File
Auto Trait Implementations§
impl Freeze for File
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnwindSafe for File
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