forked from rust-lang/annotate-snippets-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpected_type.rs
28 lines (26 loc) · 1.09 KB
/
expected_type.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use annotate_snippets::{AnnotationKind, Group, Level, Renderer, Snippet};
fn main() {
let source = r#" annotations: vec![SourceAnnotation {
label: "expected struct `annotate_snippets::snippet::Slice`, found reference"
,
range: <22, 25>,"#;
let message =
Level::ERROR.header("expected type, found `22`").group(
Group::new().element(
Snippet::source(source)
.line_start(26)
.origin("examples/footer.rs")
.fold(true)
.annotation(AnnotationKind::Primary.span(193..195).label(
"expected struct `annotate_snippets::snippet::Slice`, found reference",
))
.annotation(
AnnotationKind::Context
.span(34..50)
.label("while parsing this struct"),
),
),
);
let renderer = Renderer::styled();
anstream::println!("{}", renderer.render(message));
}