pub trait ShiftSpans {
// Required method
fn shift_spans<F: Fn(&mut Span)>(&mut self, shift: &F);
}Expand description
Shift every Span reachable inside self by applying shift.
Used by the parser at the public parse() boundary to map
inner-parser spans (in BOM-stripped coordinates) back to the
caller’s frame when a leading BOM was stripped before
tokenization.
Architectural discipline (round-18). Pre-round-18, span
shifting was a single monolithic function in the parser that did
named-field destructure on every Directive variant. That caught
added fields but missed added Spanned-bearing VARIANTS of a nested
type (e.g., a future MetaValue::String(Spanned<String>) would
silently bypass shifting because the destructure binds meta: _).
Round 18 propagates the discipline into the type system: every
type reachable from Directive either implements ShiftSpans to
delegate into its fields (compound types) or implements it as a
no-op (leaf types with no spans). Adding a new field or new
Spanned-bearing variant requires updating the type’s own impl —
the parser’s shift call doesn’t change.
Implementors must recurse into every field that COULD contain
(transitively) a Span. The provided impls for Vec<T>,
Option<T>, Box<T>, and Spanned<T> handle the common
compound shapes; concrete leaf types handle themselves.
Required Methods§
Sourcefn shift_spans<F: Fn(&mut Span)>(&mut self, shift: &F)
fn shift_spans<F: Fn(&mut Span)>(&mut self, shift: &F)
Apply shift to every Span reachable in self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".