Skip to content

Commit 17e9e22

Browse files
author
Zibi Braniecki
committed
Better example for DisplayList
1 parent d8064b0 commit 17e9e22

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/display_list.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
//!
66
//! ```
77
//! use annotate_snippets::snippet::{Snippet, Slice, Annotation, TitleAnnotation, AnnotationType};
8-
//! use annotate_snippets::display_list::{DisplayList, DisplayLine};
8+
//! use annotate_snippets::display_list::{DisplayList, DisplayLine, DisplayAnnotationType};
99
//!
1010
//! let snippet = Snippet {
1111
//! slice: Slice {
12-
//! source: r#"id: Some()"#.to_string(),
12+
//! source: "id: Option<>,\nlabel: Option<String>".to_string(),
1313
//! line_start: 145,
1414
//! origin: Some("src/display_list.rs".to_string())
1515
//! },
@@ -24,7 +24,7 @@
2424
//! Annotation {
2525
//! label: Some("expected 1 parameter".to_string()),
2626
//! annotation_type: AnnotationType::Error,
27-
//! range: Some((19, 23))
27+
//! range: Some((4, 12))
2828
//! }
2929
//! ]
3030
//! };
@@ -36,7 +36,18 @@
3636
//! DisplayLine::Source {
3737
//! lineno: 145,
3838
//! inline_marks: vec![],
39-
//! content: "id: Some()".to_string()
39+
//! content: "id: Option<>,".to_string()
40+
//! },
41+
//! DisplayLine::Annotation {
42+
//! label: "expected 1 parameter".to_string(),
43+
//! range: (4, 12),
44+
//! inline_marks: vec![],
45+
//! annotation_type: DisplayAnnotationType::Error,
46+
//! },
47+
//! DisplayLine::Source {
48+
//! lineno: 146,
49+
//! inline_marks: vec![],
50+
//! content: "label: Option<String>".to_string()
4051
//! },
4152
//! DisplayLine::EmptySource
4253
//! ]

src/snippet.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pub struct Annotation {
109109
pub annotation_type: AnnotationType,
110110
}
111111

112+
/// An annotation used to describe the whole snippet.
112113
#[derive(Debug, Clone)]
113114
pub struct TitleAnnotation {
114115
/// Identifier of the annotation. Usually error code like "E0308".

0 commit comments

Comments
 (0)