Struct codemap::File
[−]
[src]
pub struct File { pub span: Span, // some fields omitted }
A CodeMap
's record of a source file.
Fields
span: Span
The span representing the entire file.
Methods
impl File
[src]
fn name(&self) -> &str
[src]
Gets the name of the file
fn find_line(&self, pos: Pos) -> usize
[src]
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
fn find_line_col(&self, pos: Pos) -> LineCol
[src]
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
fn source(&self) -> &str
[src]
Gets the full source text of the file
fn source_slice(&self, span: Span) -> &str
[src]
fn line_span(&self, line: usize) -> Span
[src]
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
fn source_line(&self, line: usize) -> &str
[src]
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
fn num_lines(&self) -> usize
[src]
Gets the number of lines in the file
Trait Implementations
impl Debug for File
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl PartialEq for File
[src]
fn eq(&self, other: &File) -> bool
[src]
Compares by identity
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.