pub struct Template { /* private fields */ }Expand description
A field-value template.
Implementations§
Source§impl Template
impl Template
Sourcepub fn parse2(input: TokenStream) -> Result<Self, Error>
pub fn parse2(input: TokenStream) -> Result<Self, Error>
Parse a template from a TokenStream.
The TokenStream is typically all the tokens given to a macro.
Sourcepub fn before_literal_field_values<'a>(
&'a self,
) -> impl Iterator<Item = &'a FieldValue>
pub fn before_literal_field_values<'a>( &'a self, ) -> impl Iterator<Item = &'a FieldValue>
Field-values that appear before the template string literal.
Sourcepub fn literal_field_values<'a>(
&'a self,
) -> impl Iterator<Item = &'a FieldValue>
pub fn literal_field_values<'a>( &'a self, ) -> impl Iterator<Item = &'a FieldValue>
Field-values that appear within the template string literal.
This is a simple alternative to Template::visit_literal that iterates over the field-value holes.
Sourcepub fn has_literal(&self) -> bool
pub fn has_literal(&self) -> bool
Whether the template contains a literal.
Sourcepub fn after_literal_field_values<'a>(
&'a self,
) -> impl Iterator<Item = &'a FieldValue>
pub fn after_literal_field_values<'a>( &'a self, ) -> impl Iterator<Item = &'a FieldValue>
Field-values that appear after the template string literal.
Sourcepub fn visit_literal(&self, visitor: impl LiteralVisitor)
pub fn visit_literal(&self, visitor: impl LiteralVisitor)
Visit the parts of the string literal part of the template.
Each fragment of text and field-value hole will be visited in sequence.
Given a template string like:
Some text and a {hole} and some {more}.the visitor will be called with the following inputs:
visit_text("Some text and a ")visit_hole("hole")visit_text(" and some ")visit_hole("more")visit_text(".")
If the template doesn’t contain a literal then the visitor won’t be called.
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl !Send for Template
impl !Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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
Mutably borrows from an owned value. Read more