pub struct Span {
pub start: usize,
pub end: usize,
}Expand description
A span in the source code, represented as a byte range.
§#[non_exhaustive] policy
Deliberately NOT #[non_exhaustive], unlike
rustledger_parser::{ParseResult, ParseError, ParseErrorKind}.
Span is constructed via struct literal in hundreds of call sites
across the workspace (every parser rule, every test fixture, every
LSP/FFI/loader path that synthesizes a location). Marking it
non-exhaustive would force a workspace-wide migration to
Span::new for zero practical benefit — the struct has carried
the same two fields since the project’s inception and there is no
realistic future field that would justify breaking that surface.
If a future need arises (e.g., line: Option<u32> for faster LSP
position lookups), the right move is to add a sibling type with
non_exhaustive rather than retrofit it onto Span.
Fields§
§start: usizeStart byte offset (inclusive).
end: usizeEnd byte offset (exclusive).
Implementations§
Source§impl Span
impl Span
Sourcepub const ZERO: Self
pub const ZERO: Self
The zero span (0..0). Used as the location for programmatically
synthesized values that have no source representation. Pair with
SYNTHESIZED_FILE_ID on the containing Spanned to make the
“no source” intent unambiguous.
use rustledger_core::Span;
assert_eq!(Span::ZERO, Span::new(0, 0));
assert!(Span::ZERO.is_empty());Sourcepub const fn from_range(range: Range<usize>) -> Self
pub const fn from_range(range: Range<usize>) -> Self
Create a span from a range.
Sourcepub fn merge(&self, other: &Self) -> Self
pub fn merge(&self, other: &Self) -> Self
Merge this span with another, returning a span that covers both.
Sourcepub const fn into_range(self) -> Range<usize>
pub const fn into_range(self) -> Range<usize>
Convert to a byte-offset Range<usize> for downstream span consumers.
Trait Implementations§
Source§impl Archive for Span
impl Archive for Span
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedSpan
type Archived = ArchivedSpan
Source§type Resolver = SpanResolver
type Resolver = SpanResolver
impl Copy for Span
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
Source§impl ShiftSpans for Span
impl ShiftSpans 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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.