pub struct CapturedFragment<'tokens> { /* private fields */ }Expand description
One borrowed run of captured tokens under its original source boundary.
A fragment is a view into one CapturedInput or one captured group, never a second token tree.
Its producer spans remain on the tokens it borrows, while its canonical bytes exclude those producer-local coordinates on the same terms as the complete capture.
Implementations§
Source§impl<'tokens> CapturedFragment<'tokens>
impl<'tokens> CapturedFragment<'tokens>
Sourcepub fn cursor(self) -> CaptureCursor<'tokens>
pub fn cursor(self) -> CaptureCursor<'tokens>
Open the generic mechanical cursor over this exact fragment.
Source§impl<'tokens> CapturedFragment<'tokens>
impl<'tokens> CapturedFragment<'tokens>
Sourcepub const fn tokens(self) -> &'tokens [CapturedTokenTree]
pub const fn tokens(self) -> &'tokens [CapturedTokenTree]
The exact captured tokens this fragment borrows.
Sourcepub const fn is_empty(self) -> bool
pub const fn is_empty(self) -> bool
Whether this fragment carries no token at its current level.
Sourcepub fn first_span(self) -> Option<SpanHandle>
pub fn first_span(self) -> Option<SpanHandle>
The first token’s producer span, where the fragment is nonempty.
Sourcepub fn last_span(self) -> Option<SpanHandle>
pub fn last_span(self) -> Option<SpanHandle>
The last token’s producer span, where the fragment is nonempty.
Sourcepub const fn enclosing_span(self) -> Option<SpanHandle>
pub const fn enclosing_span(self) -> Option<SpanHandle>
The enclosing group span used when a read reaches this fragment’s end.
A top-level fragment has no enclosing group and therefore answers None.
Sourcepub fn canonical_bytes(self) -> Vec<u8> ⓘ
pub fn canonical_bytes(self) -> Vec<u8> ⓘ
The canonical captured bytes of exactly this fragment.
Producer spans remain excluded, so a span-only movement does not move these bytes.
Source§impl CapturedFragment<'_>
impl CapturedFragment<'_>
Sourcepub fn generated(self) -> Result<GeneratedTree, FragmentGenerationRefusal>
pub fn generated(self) -> Result<GeneratedTree, FragmentGenerationRefusal>
Project this exact captured fragment into one generated tree.
Every token is converted structurally. No inspected source string is built or parsed, and the captured fragment remains available with its original span handles.
§Errors
Returns the exact captured span where an admitted generated literal or generated-token magnitude refuses.
Trait Implementations§
Source§impl<'tokens> Clone for CapturedFragment<'tokens>
impl<'tokens> Clone for CapturedFragment<'tokens>
Source§fn clone(&self) -> CapturedFragment<'tokens>
fn clone(&self) -> CapturedFragment<'tokens>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more