pub struct SourceSpan {
pub source: Option<SourceId>,
pub byte_start: usize,
pub byte_end: usize,
pub line: usize,
pub column: usize,
pub end_line: usize,
pub end_column: usize,
}Expand description
Byte and line/column location for source-backed items.
Byte offsets are zero-based and half-open: byte_start..byte_end.
Lines and columns are one-based. End line and column identify the position
immediately after the final character in the span, so an empty span has the
same start and end position.
Fields§
§source: Option<SourceId>Source identifier, when the span came from a named parsed source.
byte_start: usizeByte offset where the item starts.
byte_end: usizeByte offset where the item ends.
line: usizeLine number where the item starts (1-indexed).
column: usizeColumn number where the item starts (1-indexed).
end_line: usizeLine number immediately after the item ends (1-indexed).
end_column: usizeColumn number immediately after the item ends (1-indexed).
Implementations§
Source§impl SourceSpan
impl SourceSpan
Sourcepub const fn new(
byte_start: usize,
byte_end: usize,
line: usize,
column: usize,
) -> Self
pub const fn new( byte_start: usize, byte_end: usize, line: usize, column: usize, ) -> Self
Create a new source span.
Sourcepub const fn with_end(
byte_start: usize,
byte_end: usize,
line: usize,
column: usize,
end_line: usize,
end_column: usize,
) -> Self
pub const fn with_end( byte_start: usize, byte_end: usize, line: usize, column: usize, end_line: usize, end_column: usize, ) -> Self
Create a new source span with explicit start and end positions.
Sourcepub const fn with_source(self, source: SourceId) -> Self
pub const fn with_source(self, source: SourceId) -> Self
Return this span associated with a source identifier.
Trait Implementations§
Source§impl Clone for SourceSpan
impl Clone for SourceSpan
Source§fn clone(&self) -> SourceSpan
fn clone(&self) -> SourceSpan
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SourceSpan
impl Debug for SourceSpan
Source§impl PartialEq for SourceSpan
impl PartialEq for SourceSpan
Source§fn eq(&self, other: &SourceSpan) -> bool
fn eq(&self, other: &SourceSpan) -> bool
self and other values to be equal, and is used by ==.impl Copy 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more