#[non_exhaustive]pub struct Span {
pub file: Arc<Path>,
pub byte_range: Range<u32>,
pub line: u32,
pub column: u32,
}Expand description
Byte-offset + line/column span into a source file.
Spans are cheap to clone (Arc<Path> is a single ref-count bump). Per
[10-data-model.md § 2.5 (I-IR-1)], every Span in the workspace IR
resolves to a path underneath the workspace root — discovery enforces
this; Span itself does not validate the path (it accepts already-trusted
values from the loader).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.file: Arc<Path>Path of the source file the span points into.
byte_range: Range<u32>Half-open byte range [start, end) into the file’s contents.
line: u321-based line number of byte_range.start.
column: u321-based column (in bytes) of byte_range.start.
Implementations§
Source§impl Span
impl Span
Sourcepub fn new(
file: Arc<Path>,
byte_range: Range<u32>,
line: u32,
column: u32,
) -> Result<Self, ValidationError>
pub fn new( file: Arc<Path>, byte_range: Range<u32>, line: u32, column: u32, ) -> Result<Self, ValidationError>
Construct a span, validating that byte_range is well-ordered and
line/column are 1-based.
§Errors
Returns ValidationError::Shape if any invariant is violated.
Sourcepub fn synthetic() -> Self
pub fn synthetic() -> Self
A synthetic 1-byte span used for IR nodes that did not originate in a file (e.g. defaults injected by the evaluator). Carries an empty path.
Sourcepub fn byte_range_usize(&self) -> Range<usize>
pub fn byte_range_usize(&self) -> Range<usize>
Convenience accessor for the byte range as a usize slice into a
source buffer.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Span
impl<'de> Deserialize<'de> for Span
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnsafeUnpin for Span
impl UnwindSafe for Span
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.