Struct deno_ast::TextLines

source ·
pub struct TextLines { /* private fields */ }

Implementations§

source§

impl TextLines

source

pub fn new(text: &str) -> TextLines

Creates a new TextLines with the specified text and default indent width of 4.

source

pub fn with_indent_width(text: &str, indent_width: usize) -> TextLines

Creates a new TextLines with the specified text and indent width. The indent width sets the width of a tab character when getting the display column.

source

pub fn lines_count(&self) -> usize

Gets the number of lines in the text.

source

pub fn text_length(&self) -> usize

Gets the text length in bytes.

source

pub fn line_index(&self, byte_index: usize) -> usize

Gets the line index from a byte index. Note that if you provide the middle byte index of a \r\n newline then it will return the index of the preceding line.

source

pub fn line_start(&self, line_index: usize) -> usize

Gets the line start byte index.

source

pub fn line_end(&self, line_index: usize) -> usize

Gets the line end byte index (before/at the newline character).

source

pub fn line_range(&self, line_index: usize) -> (usize, usize)

Gets the line range.

source

pub fn byte_index(&self, line_and_column: LineAndColumnIndex) -> usize

Gets the byte position from the provided line and column index.

source

pub fn byte_index_from_char_index(&self, char_index: usize) -> usize

Gets a byte index from the provided character index.

source

pub fn char_index(&self, byte_index: usize) -> usize

Gets a character index from the provided byte index.

source

pub fn line_and_column_index(&self, byte_index: usize) -> LineAndColumnIndex

Gets the line and column index of the provided byte index.

source

pub fn line_and_column_display(&self, byte_index: usize) -> LineAndColumnDisplay

Gets the line and column display based on the indentation width and the provided byte index.

source

pub fn line_and_column_display_with_indent_width( &self, byte_index: usize, indent_width: usize ) -> LineAndColumnDisplay

Gets the line and column display based on the provided byte index and indentation width.

Trait Implementations§

source§

impl Debug for TextLines

source§

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

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

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

source§

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