#[non_exhaustive]pub struct TemplateOutput {
pub template_position: usize,
pub overall_position: usize,
pub rendered_range: Range<usize>,
}Expand description
Rich output for a single template section.
This captures the exact string produced for one template section during formatting, along with both its template-only and overall section positions.
The output itself is represented as a byte range into
RichFormatResult::rendered, which avoids retaining a second owned string
for every template section collected through the rich rendering path.
§Examples
use string_pipeline::Template;
let template = Template::parse("A: {upper} B: {lower}").unwrap();
let result = template.format_rich("MiXeD").unwrap();
assert_eq!(result.template_outputs()[0].template_position(), 0);
assert_eq!(result.template_outputs()[0].overall_position(), 1);
assert_eq!(result.template_output(0), Some("MIXED"));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.template_position: usizePosition among template sections only.
overall_position: usizePosition among all sections, including literals.
rendered_range: Range<usize>Byte range within RichFormatResult::rendered for this template section.
Implementations§
Source§impl TemplateOutput
impl TemplateOutput
Sourcepub fn template_position(&self) -> usize
pub fn template_position(&self) -> usize
Position among template sections only.
Sourcepub fn overall_position(&self) -> usize
pub fn overall_position(&self) -> usize
Position among all sections, including literals.
Sourcepub fn rendered_range(&self) -> Range<usize>
pub fn rendered_range(&self) -> Range<usize>
Byte range within RichFormatResult::rendered for this template section.
Sourcepub fn as_str<'a>(&self, rendered: &'a str) -> &'a str
pub fn as_str<'a>(&self, rendered: &'a str) -> &'a str
Borrow this section’s rendered output from the full rendered string.
This is the zero-allocation way to inspect a single template section
once you have a RichFormatResult.
Trait Implementations§
Source§impl Clone for TemplateOutput
impl Clone for TemplateOutput
Source§fn clone(&self) -> TemplateOutput
fn clone(&self) -> TemplateOutput
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more