pub struct File<T>where
T: FileData,{
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<T> File<T>where
T: FileData,
impl<T> File<T>where
T: FileData,
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<T> Eq for File<T>where
T: FileData,
Auto Trait Implementations§
impl<T> Freeze for File<T>where
T: Freeze,
impl<T> RefUnwindSafe for File<T>where
T: RefUnwindSafe,
impl<T> Send for File<T>where
T: Send,
impl<T> Sync for File<T>where
T: Sync,
impl<T> Unpin for File<T>where
T: Unpin,
impl<T> UnwindSafe for File<T>where
T: UnwindSafe,
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