Struct diagnostic::Source
source · pub struct Source {
pub length: u32,
/* private fields */
}Expand description
A type representing a single source that may be referred to by [Span]s.
In most cases, a source is a single input file.
Fields§
§length: u32bytes in source
Implementations§
source§impl Source
impl Source
sourcepub fn get_length(&self) -> usize
pub fn get_length(&self) -> usize
Get the length of the total number of characters in the source.
sourcepub fn chars(&self) -> impl Iterator<Item = char> + '_
pub fn chars(&self) -> impl Iterator<Item = char> + '_
Return an iterator over the characters in the source.
sourcepub fn lines(&self) -> impl ExactSizeIterator<Item = &Line> + '_
pub fn lines(&self) -> impl ExactSizeIterator<Item = &Line> + '_
Return an iterator over the Lines in this source.
sourcepub fn get_offset_line(&self, offset: u32) -> Option<(&Line, usize, u32)>
pub fn get_offset_line(&self, offset: u32) -> Option<(&Line, usize, u32)>
Get the line that the given offset appears on, and the line/column numbers of the offset.
Note that the line/column numbers are zero-indexed.
sourcepub fn set_remote(&mut self, url: Url) -> bool
pub fn set_remote(&mut self, url: Url) -> bool
Set path name of source
sourcepub fn with_remote(self, url: Url) -> Self
pub fn with_remote(self, url: Url) -> Self
Get path name of source
sourcepub fn get_line_range(&self, span: &Range<u32>) -> Range<usize>
pub fn get_line_range(&self, span: &Range<u32>) -> Range<usize>
Get the range of lines that this span runs across.
The resulting range is guaranteed to contain valid line indices (i.e: those that can be used for
Source::line).
Trait Implementations§
source§impl PartialEq for Source
impl PartialEq for Source
impl Eq for Source
impl StructuralPartialEq for Source
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