]> git.proxmox.com Git - rustc.git/blobdiff - vendor/annotate-snippets-0.6.1/examples/multislice.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / vendor / annotate-snippets-0.6.1 / examples / multislice.rs
diff --git a/vendor/annotate-snippets-0.6.1/examples/multislice.rs b/vendor/annotate-snippets-0.6.1/examples/multislice.rs
new file mode 100644 (file)
index 0000000..af1cb15
--- /dev/null
@@ -0,0 +1,34 @@
+use annotate_snippets::display_list::DisplayList;
+use annotate_snippets::formatter::DisplayListFormatter;
+use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet};
+
+fn main() {
+    let snippet = Snippet {
+        title: Some(Annotation {
+            label: Some("mismatched types".to_string()),
+            id: None,
+            annotation_type: AnnotationType::Error,
+        }),
+        footer: vec![],
+        slices: vec![
+            Slice {
+                source: "Foo".to_string(),
+                line_start: 51,
+                origin: Some("src/format.rs".to_string()),
+                fold: false,
+                annotations: vec![],
+            },
+            Slice {
+                source: "Faa".to_string(),
+                line_start: 129,
+                origin: Some("src/display.rs".to_string()),
+                fold: false,
+                annotations: vec![],
+            },
+        ],
+    };
+
+    let dl = DisplayList::from(snippet);
+    let dlf = DisplayListFormatter::new(true, false);
+    println!("{}", dlf.format(&dl));
+}