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(n) in source_code’s length plus the number of labels.

§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"));