pub struct SourceText { /* private fields */ }Expand description
Immutable file contents together with a line index, built the first time a line is asked for: most files a search loads are never located in.
Implementations§
Source§impl SourceText
impl SourceText
pub fn new(text: impl Into<String>) -> Self
pub fn as_str(&self) -> &str
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn get(&self, span: Span) -> Result<&str, SpanError>
pub fn get(&self, span: Span) -> Result<&str, SpanError>
Read a range received from a plugin or client without unchecked indexing.
pub fn position(&self, offset: usize) -> Position
Sourcepub fn offset(&self, position: Position) -> Option<usize>
pub fn offset(&self, position: Position) -> Option<usize>
The byte offset of position, None past the end of the file.
Sourcepub fn line(&self, line: usize) -> Option<&str>
pub fn line(&self, line: usize) -> Option<&str>
The text of the zero-based line, without its terminator.
pub fn line_index(&self) -> &LineIndex
Trait Implementations§
Source§impl Clone for SourceText
impl Clone for SourceText
Source§impl Debug for SourceText
impl Debug for SourceText
Source§impl From<&str> for SourceText
impl From<&str> for SourceText
Auto Trait Implementations§
impl !Freeze for SourceText
impl RefUnwindSafe for SourceText
impl Send for SourceText
impl Sync for SourceText
impl Unpin for SourceText
impl UnsafeUnpin for SourceText
impl UnwindSafe for SourceText
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