CodeMap

Struct CodeMap 

Source
pub struct CodeMap<T: FileData = DefaultFileData> { /* private fields */ }
Expand description

A data structure recording source code files for position lookup.

Implementations§

Source§

impl<T: FileData> CodeMap<T>

Source

pub fn new() -> Self

Creates an empty CodeMap.

Source

pub fn add_file(&mut self, source: T) -> Arc<File<T>>

Adds a file with the given name and contents.

Use the returned File and its .span property to create Spans representing substrings of the file.

Source

pub fn find_file(&self, pos: Pos) -> &Arc<File<T>>

Looks up the File that contains the specified position.

Source

pub fn look_up_pos(&self, pos: Pos) -> Loc<T>

Gets the file, line, and column represented by a Pos.

Source

pub fn look_up_span(&self, span: Span) -> SpanLoc<T>

Gets the file and its line and column ranges represented by a Span.

Trait Implementations§

Source§

impl<T: Debug + FileData> Debug for CodeMap<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Default + FileData> Default for CodeMap<T>

Source§

fn default() -> CodeMap<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for CodeMap<T>

§

impl<T> RefUnwindSafe for CodeMap<T>
where T: RefUnwindSafe,

§

impl<T> Send for CodeMap<T>
where T: Sync + Send,

§

impl<T> Sync for CodeMap<T>
where T: Sync + Send,

§

impl<T> Unpin for CodeMap<T>

§

impl<T> UnwindSafe for CodeMap<T>
where T: RefUnwindSafe,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.