pub struct SourceSpan {
pub start_inclusive: SourcePosition,
pub end_exclusive: SourcePosition,
pub file_path: Option<PathBuf>,
}Expand description
Represents a span of source text from start to end position.
The span is a half-open interval: [start_inclusive, end_exclusive).
start_inclusive: Position of the first character of the source textend_exclusive: Position immediately after the last character
Optionally includes a file path for the referenced source text.
Fields§
§start_inclusive: SourcePosition§end_exclusive: SourcePosition§file_path: Option<PathBuf>The file path to the source text this span refers to, if available.
Implementations§
Source§impl SourceSpan
impl SourceSpan
Sourcepub fn line_col(&self) -> ((u32, u32), (u32, u32))
pub fn line_col(&self) -> ((u32, u32), (u32, u32))
Returns ((start_line, start_col), (end_line, end_col))
as 0-based u32 tuples.
Delegates to
SourcePosition::line_col()
on both endpoints.
Sourcepub fn new(start: SourcePosition, end: SourcePosition) -> Self
pub fn new(start: SourcePosition, end: SourcePosition) -> Self
Creates a span without file path information.
Sourcepub fn with_file(
start: SourcePosition,
end: SourcePosition,
file_path: PathBuf,
) -> Self
pub fn with_file( start: SourcePosition, end: SourcePosition, file_path: PathBuf, ) -> Self
Creates a span with file path information.
Trait Implementations§
Source§impl Clone for SourceSpan
impl Clone for SourceSpan
Source§fn clone(&self) -> SourceSpan
fn clone(&self) -> SourceSpan
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SourceSpan
impl Debug for SourceSpan
Source§impl PartialEq for SourceSpan
impl PartialEq for SourceSpan
impl Eq for SourceSpan
impl StructuralPartialEq for SourceSpan
Auto Trait Implementations§
impl Freeze for SourceSpan
impl RefUnwindSafe for SourceSpan
impl Send for SourceSpan
impl Sync for SourceSpan
impl Unpin for SourceSpan
impl UnsafeUnpin for SourceSpan
impl UnwindSafe for SourceSpan
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