-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathexpected_type.rs
42 lines (39 loc) · 1.47 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
extern crate annotate_snippets;
use annotate_snippets::display_list::DisplayList;
use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
fn main() {
let snippet = Snippet {
title: Some(Annotation {
label: Some("expected type, found `22`".to_string()),
id: None,
annotation_type: AnnotationType::Error,
}),
footer: vec![],
slices: vec![Slice {
source: r#" annotations: vec![SourceAnnotation {
label: "expected struct `annotate_snippets::snippet::Slice`, found reference"
.to_string(),
range: <22, 25>,"#
.to_string(),
line_start: 26,
origin: Some("examples/footer.rs".to_string()),
fold: true,
annotations: vec![
SourceAnnotation {
label: "".to_string(),
annotation_type: AnnotationType::Error,
range: (208, 210),
},
SourceAnnotation {
label: "while parsing this struct".to_string(),
annotation_type: AnnotationType::Info,
range: (34, 50),
},
],
}],
};
let dl = DisplayList::from(snippet);
let dlf = DisplayListFormatter::new(true);
println!("{}", dlf.format(&dl));
}