Skip to main content

format_multi_span

Function format_multi_span 

Source
pub fn format_multi_span(
    title: &str,
    labels: &[SpanLabel],
    source_code: &str,
    filename: &str,
    start_line: u32,
    renderer: &Renderer,
) -> String
Expand description

Renders title with several labelled annotations over source_code, the first as the primary caret and the rest as secondary context, in rustc style.

  • Precondition: labels is non-empty.
  • Complexity: O(k * s + l) annotation work for k labels, s source bytes and l label bytes, plus renderer layout; O(k + s + b) auxiliary/output space for b output bytes.

ยงExamples

use annotate_snippets::Renderer;
use cel_parser::{SourceSpan, SpanLabel, format_multi_span};

let labels = vec![SpanLabel { span: SourceSpan::new(1, 0, 1, 1), label: "here".into() }];
let out = format_multi_span("oops", &labels, "x", "f.adm2", 1, &Renderer::plain());
assert!(out.contains("oops"));