]>
git.proxmox.com Git - rustc.git/blob - vendor/annotate-snippets/src/snippet.rs
1 //! Structures used as an input for the library.
6 //! use annotate_snippets::snippet::*;
9 //! title: Some(Annotation {
10 //! label: Some("mismatched types".to_string()),
12 //! annotation_type: AnnotationType::Error,
17 //! source: "Foo".to_string(),
19 //! origin: Some("src/format.rs".to_string()),
21 //! annotations: vec![],
24 //! source: "Faa".to_string(),
26 //! origin: Some("src/display.rs".to_string()),
28 //! annotations: vec![],
33 /// Primary structure provided for formatting
34 #[derive(Debug, Clone)]
36 pub title
: Option
<Annotation
>,
37 pub footer
: Vec
<Annotation
>,
38 pub slices
: Vec
<Slice
>,
41 /// Structure containing the slice of text to be annotated and
42 /// basic information about the location of the slice.
43 #[derive(Debug, Clone)]
46 pub line_start
: usize,
47 pub origin
: Option
<String
>,
48 pub annotations
: Vec
<SourceAnnotation
>,
49 /// If set explicitly to `true`, the snippet will fold
50 /// parts of the slice that don't contain any annotations.
54 /// Types of annotations.
55 #[derive(Debug, Clone, Copy)]
56 pub enum AnnotationType
{
57 /// Error annotations are displayed using red color and "^" character.
59 /// Warning annotations are displayed using blue color and "-" character.
66 /// An annotation for a `Slice`.
67 #[derive(Debug, Clone)]
68 pub struct SourceAnnotation
{
69 pub range
: (usize, usize),
71 pub annotation_type
: AnnotationType
,
74 /// An annotation for a `Snippet`.
75 #[derive(Debug, Clone)]
76 pub struct Annotation
{
77 /// Identifier of the annotation. Usually error code like "E0308".
78 pub id
: Option
<String
>,
79 pub label
: Option
<String
>,
80 pub annotation_type
: AnnotationType
,