Skip to main content

SourceFile

Struct SourceFile 

Source
pub struct SourceFile {
    pub name: String,
    pub src: String,
    pub start: usize,
    /* private fields */
}
Expand description

A loaded source file and the global positions it occupies.

Fields§

§name: String

The name shown in diagnostics, usually the path as given.

§src: String§start: usize

Global position of the file’s first byte.

Implementations§

Source§

impl SourceFile

Source

pub fn end(&self) -> usize

Global position one past the file’s last byte.

Source

pub fn span(&self) -> Span

The span of the whole file.

Source

pub fn contains(&self, pos: usize) -> bool

Source

pub fn slice(&self, span: Span) -> &str

The source text covered by span, which must lie in this file.

Source

pub fn line_col(&self, pos: usize) -> LineCol

The line/column of global position pos, which may be the end of the file.

Trait Implementations§

Source§

impl Debug for SourceFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for SourceFile

§

impl Freeze for SourceFile

§

impl Move for SourceFile

§

impl RefUnwindSafe for SourceFile

§

impl Send for SourceFile
where RawVecInner: Send,

§

impl Sync for SourceFile
where RawVecInner: Sync,

§

impl Unpin for SourceFile
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for SourceFile

§

impl UnwindSafe for SourceFile
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.