Skip to main content

SourceMap

Struct SourceMap 

Source
pub struct SourceMap(/* private fields */);
Expand description

A collection of SourceMarker.

Sourcemaps are used to map positions in the original source to positions in the transformed code. Here, only the boundaries of edits are tracked instead of every single character.

This mapping maintains the invariant that markers are in source order.

Implementations§

Source§

impl SourceMap

Source

pub fn markers(&self) -> &[SourceMarker]

Returns a slice of all the markers in the sourcemap in source order.

Source

pub fn push_start_marker(&mut self, edit: &Edit, output_length: TextSize)

Push the start marker for an Edit.

The output_length is the length of the transformed string before the edit is applied.

§Panics

If the start of edit is less than previous markers.

Source

pub fn push_end_marker(&mut self, edit: &Edit, output_length: TextSize)

Push the end marker for an Edit.

The output_length is the length of the transformed string after the edit has been applied.

§Panics

If edit falls before previous markers.

Source

pub fn push_marker(&mut self, offset: TextSize, output_length: TextSize)

Push a new marker to the sourcemap.

§Panics

If offset is less than previous markers.

Trait Implementations§

Source§

impl Default for SourceMap

Source§

fn default() -> SourceMap

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

impl Eq for SourceMap

Source§

impl PartialEq for SourceMap

Source§

fn eq(&self, other: &SourceMap) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SourceMap

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.