pub struct Span {
pub start: u32,
pub end: u32,
}Expand description
A half-open byte range [start, end) into some source string.
Fields§
§start: u32§end: u32Implementations§
Source§impl Span
impl Span
pub const fn new(start: u32, end: u32) -> Self
pub const fn point(offset: u32) -> Self
Sourcepub const fn len(self) -> u32
pub const fn len(self) -> u32
Byte-width of the half-open range [start, end). pub const fn —
u32::saturating_sub is const-stable since Rust 1.47, well before
this workspace’s 1.89 MSRV floor, so the promotion is a body-
preserving type-signature widening. Matches the sibling
Self::new / Self::point / Self::contains /
Self::union pub const fn shape on the same Span primitive
— every downstream consumer that wants a compile-time span-width
fixture (a const WIDTH: u32 = SPAN.len(); LSP hover-registry
entry, a per-diagnostic const-context width oracle a future
admission webhook consults, a compile-time span-partition truth
table the caixa-fmt trivia-owner resolver keys off) now reads
through one substrate-primitive const dispatch rather than being
forced onto the runtime code path.
Sourcepub const fn is_empty(self) -> bool
pub const fn is_empty(self) -> bool
Half-open emptiness predicate — true iff self.start == self.end.
pub const fn — folds onto the sibling Self::len pub const fn promotion (integer equality is const in Rust since long before
this workspace’s 1.89 MSRV floor). Matches every other accessor /
predicate on this Span primitive’s const-eval surface; only
the fundamentally-runtime-only slice(&str) method (string-slice
indexing outside const-eval) remains pub fn.
Sourcepub const fn union(self, other: Span) -> Span
pub const fn union(self, other: Span) -> Span
The smallest span covering both. Useful for building a list node’s
span from its children — every parser code path that composes a
parent span from its immediate child boundaries reads through this
(open.union(close) on a delimited list, head.union(target.span)
on a quote-form target, and every downstream trivia-owner /
diagnostic-aggregator / fmt-region parent-span builder). pub const fn — the body reaches for u32::min / u32::max, both const
stable since Rust 1.83 (well before this workspace’s 1.89 MSRV
floor), so the promotion is a body-preserving type-signature
widening. Matches the sibling Self::new / Self::point /
Self::contains pub const fn shape on the same Span
primitive — every downstream consumer that wants a compile-time
span-composition fixture (a const OUTER: Span = INNER1.union( INNER2); LSP hover-registry entry, a per-diagnostic const-context
parent-span oracle a future admission webhook consults, a
compile-time span-partition truth table the caixa-fmt trivia-owner
resolver keys off) now reads through one substrate-primitive const
dispatch rather than being forced onto the runtime code path.
pub fn slice<'a>(self, src: &'a str) -> &'a str
Sourcepub const fn contains(self, offset: u32) -> bool
pub const fn contains(self, offset: u32) -> bool
Byte-offset half-open containment predicate every consumer that
keys off an author-authored source position (LSP hover
span-lookup at the cursor, per-diagnostic span-registry probe,
per-trivia leading/trailing-owner attachment gate) reads through
— returns true iff offset lies inside the half-open range
[self.start, self.end). pub const fn — matches the sibling
Self::new / Self::point pub const fn shape on the same
Span primitive’s construction axis, extending the const-eval
surface onto the primitive’s containment-predicate axis without
a body change (integer comparison is const in Rust since long
before this workspace’s 1.89 MSRV floor). Every downstream
consumer that wants a compile-time span-containment fixture —
a const IS_INSIDE: bool = SPAN.contains(OFFSET); LSP hover-
registry entry, a per-diagnostic const-context span oracle a
future admission webhook consults, a compile-time span-partition
truth table the caixa-fmt trivia-owner resolver keys off — now
reads through one substrate-primitive const dispatch rather than
being forced onto the runtime code path.
Trait Implementations§
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
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,
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<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.