pub struct Lines<S>(/* private fields */);Expand description
A text buffer and metadata about lines.
This is internally reference-counted and thus cheap to clone.
Implementations§
Source§impl<T: AsRef<str>> Lines<T>
impl<T: AsRef<str>> Lines<T>
Sourcepub fn byte_to_utf16(&self, byte_idx: usize) -> Option<usize>
pub fn byte_to_utf16(&self, byte_idx: usize) -> Option<usize>
Return the index of the UTF-16 code unit at the byte index.
Sourcepub fn byte_to_line(&self, byte_idx: usize) -> Option<usize>
pub fn byte_to_line(&self, byte_idx: usize) -> Option<usize>
Return the index of the line that contains the given byte index.
Sourcepub fn byte_to_column(&self, byte_idx: usize) -> Option<usize>
pub fn byte_to_column(&self, byte_idx: usize) -> Option<usize>
Return the index of the column at the byte index.
The column is defined as the number of characters in the line before the byte index.
Sourcepub fn byte_to_line_column(&self, byte_idx: usize) -> Option<(usize, usize)>
pub fn byte_to_line_column(&self, byte_idx: usize) -> Option<(usize, usize)>
Return the index of the line and column at the byte index.
Sourcepub fn utf16_to_byte(&self, utf16_idx: usize) -> Option<usize>
pub fn utf16_to_byte(&self, utf16_idx: usize) -> Option<usize>
Return the byte index at the UTF-16 code unit.
Sourcepub fn line_to_byte(&self, line_idx: usize) -> Option<usize>
pub fn line_to_byte(&self, line_idx: usize) -> Option<usize>
Return the byte position at which the given line starts.
Source§impl Lines<String>
impl Lines<String>
Sourcepub fn replace(&mut self, new: &str) -> bool
pub fn replace(&mut self, new: &str) -> bool
Fully replace the source text.
This performs a naive (suffix/prefix-based) diff of the old and new text
to produce the smallest single edit that transforms old into new and
then calls edit with it.
Returns whether any changes were made.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Lines<S>
impl<S> RefUnwindSafe for Lines<S>where
S: RefUnwindSafe,
impl<S> Send for Lines<S>
impl<S> Sync for Lines<S>
impl<S> Unpin for Lines<S>
impl<S> UnwindSafe for Lines<S>where
S: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more