[][src]Struct codemap::File

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]

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]

Gets the source text of a Span.

Panics

  • If span is not entirely within this file.

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]

impl PartialEq<File> for File[src]

fn eq(&self, other: &File) -> bool[src]

Compares by identity

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.