]>
Commit | Line | Data |
---|---|---|
dc9dc135 XL |
1 | extern crate annotate_snippets; |
2 | ||
3 | use annotate_snippets::display_list::DisplayList; | |
4 | use annotate_snippets::formatter::DisplayListFormatter; | |
5 | use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet}; | |
6 | ||
7 | fn main() { | |
8 | let snippet = Snippet { | |
9 | title: Some(Annotation { | |
10 | label: Some("mismatched types".to_string()), | |
11 | id: None, | |
12 | annotation_type: AnnotationType::Error, | |
13 | }), | |
14 | footer: vec![], | |
15 | slices: vec![ | |
16 | Slice { | |
17 | source: "Foo".to_string(), | |
18 | line_start: 51, | |
19 | origin: Some("src/format.rs".to_string()), | |
20 | fold: false, | |
21 | annotations: vec![], | |
22 | }, | |
23 | Slice { | |
24 | source: "Faa".to_string(), | |
25 | line_start: 129, | |
26 | origin: Some("src/display.rs".to_string()), | |
27 | fold: false, | |
28 | annotations: vec![], | |
29 | }, | |
30 | ], | |
31 | }; | |
32 | ||
33 | let dl = DisplayList::from(snippet); | |
34 | let dlf = DisplayListFormatter::new(true); | |
35 | println!("{}", dlf.format(&dl)); | |
36 | } |