Skip to main content

Document

Struct Document 

Source
pub(crate) struct Document {
    pub file: FileId,
    text: String,
    line_starts: Vec<usize>,
    pub parsed: Parsed,
}

Fields§

§file: FileId§text: String§line_starts: Vec<usize>

The byte offset where each line starts; the first is always 0.

§parsed: Parsed

Implementations§

Source§

impl Document

Source

pub(crate) fn new(text: String, file: FileId) -> Self

Source

pub(crate) fn source(&self) -> &str

Source

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

The text of span, which points into this file.

Source

pub(crate) fn word_start(&self, offset: usize) -> usize

Where the name ending at offset starts; offset itself when there is none.

Source

pub(crate) fn range(&self, span: Span, encoding: Encoding) -> Range

Source

pub(crate) fn position(&self, offset: usize, encoding: Encoding) -> Position

Source

pub(crate) fn offset(&self, position: Position, encoding: Encoding) -> usize

The byte offset of position. A column past the end of its line means the end of the line, and a line past the end of the file means the end of the file, as the protocol requires.

Trait Implementations§

Source§

impl Debug for Document

Source§

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

Formats the value using the given formatter. Read more

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<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.