Struct dprint_swc_ecma_ast_view::TextLines
source · [−]pub struct TextLines { /* private fields */ }
Implementations
sourceimpl TextLines
impl TextLines
sourcepub fn new(text: &str) -> TextLines
pub fn new(text: &str) -> TextLines
Creates a new TextLines
with the specified text and default
indent width of 4.
sourcepub fn with_indent_width(text: &str, indent_width: usize) -> TextLines
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.
sourcepub fn lines_count(&self) -> usize
pub fn lines_count(&self) -> usize
Gets the number of lines in the text.
sourcepub fn text_length(&self) -> usize
pub fn text_length(&self) -> usize
Gets the text length in bytes.
sourcepub fn line_index(&self, byte_index: usize) -> usize
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 line the preceding line.
sourcepub fn line_start(&self, line_index: usize) -> usize
pub fn line_start(&self, line_index: usize) -> usize
Gets the line start byte index.
sourcepub fn line_end(&self, line_index: usize) -> usize
pub fn line_end(&self, line_index: usize) -> usize
Gets the line end byte index (before/at the newline character).
sourcepub fn byte_index(&self, line_and_column: LineAndColumnIndex) -> usize
pub fn byte_index(&self, line_and_column: LineAndColumnIndex) -> usize
Gets the byte position from the provided line and column index.
sourcepub fn line_and_column_index(&self, byte_index: usize) -> LineAndColumnIndex
pub fn line_and_column_index(&self, byte_index: usize) -> LineAndColumnIndex
Gets the line and column index of the provided byte index.
sourcepub fn line_and_column_display(&self, byte_index: usize) -> LineAndColumnDisplay
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.
sourcepub fn line_and_column_display_with_indent_width(
&self,
byte_index: usize,
indent_width: usize
) -> LineAndColumnDisplay
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
Auto Trait Implementations
impl RefUnwindSafe for TextLines
impl Send for TextLines
impl Sync for TextLines
impl Unpin for TextLines
impl UnwindSafe for TextLines
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more