Matthew Maurer | 597ccd5 | 2023-06-12 16:37:41 +0000 | [diff] [blame] | 1 | use annotate_snippets::{ |
| 2 | display_list::{DisplayList, FormatOptions}, |
| 3 | snippet::{Annotation, AnnotationType, Slice, Snippet}, |
| 4 | }; |
| 5 | |
| 6 | fn main() { |
| 7 | let snippet = Snippet { |
| 8 | title: Some(Annotation { |
| 9 | label: Some("mismatched types"), |
| 10 | id: None, |
| 11 | annotation_type: AnnotationType::Error, |
| 12 | }), |
| 13 | footer: vec![], |
| 14 | slices: vec![ |
| 15 | Slice { |
| 16 | source: "Foo", |
| 17 | line_start: 51, |
| 18 | origin: Some("src/format.rs"), |
| 19 | fold: false, |
| 20 | annotations: vec![], |
| 21 | }, |
| 22 | Slice { |
| 23 | source: "Faa", |
| 24 | line_start: 129, |
| 25 | origin: Some("src/display.rs"), |
| 26 | fold: false, |
| 27 | annotations: vec![], |
| 28 | }, |
| 29 | ], |
| 30 | opt: FormatOptions { |
| 31 | color: true, |
| 32 | ..Default::default() |
| 33 | }, |
| 34 | }; |
| 35 | |
| 36 | let dl = DisplayList::from(snippet); |
| 37 | println!("{}", dl); |
| 38 | } |