• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use annotate_snippets::{
2     display_list::{DisplayList, FormatOptions},
3     snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
4 };
5 
main()6 fn main() {
7     let snippet = Snippet {
8         title: Some(Annotation {
9             label: Some("expected type, found `22`"),
10             id: None,
11             annotation_type: AnnotationType::Error,
12         }),
13         footer: vec![],
14         slices: vec![Slice {
15             source: r#"                annotations: vec![SourceAnnotation {
16                 label: "expected struct `annotate_snippets::snippet::Slice`, found reference"
17                     ,
18                 range: <22, 25>,"#,
19             line_start: 26,
20             origin: Some("examples/footer.rs"),
21             fold: true,
22             annotations: vec![
23                 SourceAnnotation {
24                     label: "",
25                     annotation_type: AnnotationType::Error,
26                     range: (193, 195),
27                 },
28                 SourceAnnotation {
29                     label: "while parsing this struct",
30                     annotation_type: AnnotationType::Info,
31                     range: (34, 50),
32                 },
33             ],
34         }],
35         opt: FormatOptions {
36             color: true,
37             ..Default::default()
38         },
39     };
40 
41     let dl = DisplayList::from(snippet);
42     println!("{}", dl);
43 }
44