[−][src]Struct codemap::File
A CodeMap
's record of a source file.
Fields
span: Span
The span representing the entire file.
Methods
impl File
[src]
pub fn name(&self) -> &str
[src]
Gets the name of the file
pub 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
pub 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
pub fn source(&self) -> &str
[src]
Gets the full source text of the file
pub fn source_slice(&self, span: Span) -> &str
[src]
pub 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
pub 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
pub fn num_lines(&self) -> usize
[src]
Gets the number of lines in the file
Trait Implementations
impl Debug for File
[src]
impl Eq for File
[src]
impl Hash for File
[src]
fn hash<H: Hasher>(&self, hasher: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<File> for File
[src]
Auto Trait Implementations
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnwindSafe for File
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,