pub struct LineIndex { /* private fields */ }Expand description
The start of every line in a text.
Implementations§
Source§impl LineIndex
impl LineIndex
Sourcepub fn new(text: &str) -> LineIndex
pub fn new(text: &str) -> LineIndex
Index text. \n ends a line, and so does \r\n, whose \r is
part of the line’s end.
Sourcepub fn position(&self, offset: u32) -> (u32, u32)
pub fn position(&self, offset: u32) -> (u32, u32)
The zero-based line and UTF-16 column of byte offset. An offset
past the end is the end of the text.
Sourcepub fn offset(&self, line: u32, column: u32) -> u32
pub fn offset(&self, line: u32, column: u32) -> u32
The byte offset of zero-based line and UTF-16 column.
Out-of-range positions clamp:
- a column past the line’s end goes to the line’s end, before its
\r\nor\n; - a line past the last goes to the end of the text;
- a column inside a surrogate pair goes to its character’s start.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LineIndex
impl RefUnwindSafe for LineIndex
impl Send for LineIndex
impl Sync for LineIndex
impl Unpin for LineIndex
impl UnsafeUnpin for LineIndex
impl UnwindSafe for LineIndex
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
Mutably borrows from an owned value. Read more