Module annotate_snippets::display_list [] [src]

DisplayList is an intermittent structure which converts the Snippet structure into a list of lines that resemble the final output.

Example:

use annotate_snippets::snippet::{Snippet, Slice, Annotation, TitleAnnotation, AnnotationType};
use annotate_snippets::display_list::{DisplayList, DisplayLine, DisplayAnnotationType};

let snippet = Snippet {
  slice: Slice {
    source: "id: Option<>,\nlabel: Option<String>".to_string(),
    line_start: 145,
    origin: Some("src/display_list.rs".to_string())
  },
  title: Some(TitleAnnotation {
      id: Some("E0061".to_string()),
      label: Some("this function takes 1 parameter but 0 parameters were supplied".to_string()),
      annotation_type: AnnotationType::Error,
  }),
  main_annotation_pos: Some(0),
  fold: Some(false),
  annotations: vec![
    Annotation {
      label: Some("expected 1 parameter".to_string()),
      annotation_type: AnnotationType::Error,
      range: Some((4, 12))
    }
  ]
};
assert_eq!(DisplayList::from(snippet), DisplayList {
    body: vec![
      DisplayLine::Raw("error[E0061]: this function takes 1 parameter but 0 parameters were supplied".to_string()),
      DisplayLine::Raw("  --> src/display_list.rs:52:1".to_string()),
      DisplayLine::EmptySource,
      DisplayLine::Source {
          lineno: 145,
          inline_marks: vec![],
          content: "id: Option<>,".to_string()
      },
      DisplayLine::Annotation {
          label: "expected 1 parameter".to_string(),
          range: (4, 12),
          inline_marks: vec![],
          annotation_type: DisplayAnnotationType::Error,
      },
      DisplayLine::Source {
          lineno: 146,
          inline_marks: vec![],
          content: "label: Option<String>".to_string()
      },
      DisplayLine::EmptySource
    ]
});

Structs

DisplayList

Enums

DisplayAnnotationType
DisplayLine
DisplayMark