pub struct Source { /* private fields */ }
Expand description
A single source file.
Implementations§
source§impl Source
impl Source
sourcepub fn new(name: impl AsRef<str>, source: impl AsRef<str>) -> Self
pub fn new(name: impl AsRef<str>, source: impl AsRef<str>) -> Self
Construct a new source with the given name.
sourcepub fn with_path(
name: impl AsRef<str>,
source: impl AsRef<str>,
path: Option<impl AsRef<Path>>
) -> Self
pub fn with_path( name: impl AsRef<str>, source: impl AsRef<str>, path: Option<impl AsRef<Path>> ) -> Self
Construct a new source with the given name.
sourcepub fn line_starts(&self) -> &[usize]
pub fn line_starts(&self) -> &[usize]
Access all line starts in the source.
sourcepub fn get<I>(&self, i: I) -> Option<&I::Output>where
I: SliceIndex<str>,
pub fn get<I>(&self, i: I) -> Option<&I::Output>where I: SliceIndex<str>,
et the given range from the source.
sourcepub fn pos_to_utf16cu_linecol(&self, offset: usize) -> (usize, usize)
pub fn pos_to_utf16cu_linecol(&self, offset: usize) -> (usize, usize)
Convert the given offset to a utf-16 line and character.
sourcepub fn pos_to_utf8_linecol(&self, offset: usize) -> (usize, usize)
pub fn pos_to_utf8_linecol(&self, offset: usize) -> (usize, usize)
Convert the given offset to a utf-16 line and character.
sourcepub fn line_index(&self, byte_index: usize) -> usize
pub fn line_index(&self, byte_index: usize) -> usize
Get the line index for the given byte.
sourcepub fn line_range(&self, line_index: usize) -> Option<Range<usize>>
pub fn line_range(&self, line_index: usize) -> Option<Range<usize>>
Get the range corresponding to the given line index.
sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Get the number of lines in the source.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnwindSafe for Source
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