pub struct TokenPath { /* private fields */ }Expand description
Where one captured token sits, as the index route from the root of the declared input.
The route is unique by construction: [3, 0, 5] is the sixth token of the first token of the fourth top-level token, and nothing else in the tree spells that.
It is stable under everything a span is not stable under — which producer read the input, where the file moved, how the source was formatted — so two captures of one declaration agree on every route.
Implementations§
Source§impl TokenPath
impl TokenPath
Sourcepub const fn root() -> Self
pub const fn root() -> Self
The root route: the declared input itself, before any step into it.
Sourcepub fn stepped(&self, index: u32) -> Result<Self, CaptureBound>
pub fn stepped(&self, index: u32) -> Result<Self, CaptureBound>
The route to one token of the group this route names.
§Errors
Returns CaptureBound::Depth where the route would run past the declared nesting magnitude.
The step refuses rather than saturating, because a saturated depth makes two different tokens share one route.