Skip to main content

ShiftSpans

Trait ShiftSpans 

Source
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§

Source

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".

Implementations on Foreign Types§

Source§

impl ShiftSpans for Date

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for String

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for bool

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for char

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for f32

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for f64

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for i8

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for i16

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for i32

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for i64

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for isize

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for u8

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for u16

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for u32

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for u64

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl ShiftSpans for usize

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, _shift: &F)

Source§

impl<K, V: ShiftSpans, S> ShiftSpans for HashMap<K, V, S>

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, shift: &F)

Source§

impl<T: ShiftSpans + ?Sized> ShiftSpans for Box<T>

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, shift: &F)

Source§

impl<T: ShiftSpans> ShiftSpans for Option<T>

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, shift: &F)

Source§

impl<T: ShiftSpans> ShiftSpans for Vec<T>

Source§

fn shift_spans<F: Fn(&mut Span)>(&mut self, shift: &F)

Implementors§