pub struct Source { /* private fields */ }Expand description
A single source file.
Implementations
sourceimpl 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 position_to_utf16cu_line_char(
&self,
offset: usize
) -> Option<(usize, usize)>
pub fn position_to_utf16cu_line_char(
&self,
offset: usize
) -> Option<(usize, usize)>
Convert the given offset to a utf-16 line and character.
sourcepub fn position_to_unicode_line_char(&self, offset: usize) -> (usize, usize)
pub fn position_to_unicode_line_char(&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
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