Skip to content

Commit bdf43be

Browse files
committed
Fix example, bench and leftover doc
1 parent 052d65b commit bdf43be

File tree

6 files changed

+25
-100
lines changed

6 files changed

+25
-100
lines changed

benches/simple.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn create_snippet() {
4747
SourceAnnotation {
4848
label: "expected enum `std::option::Option`".to_string(),
4949
annotation_type: AnnotationType::Error,
50-
range: (23, 745),
50+
range: (26, 724),
5151
},
5252
],
5353
}],
@@ -59,7 +59,7 @@ fn create_snippet() {
5959
footer: vec![],
6060
opt: FormatOptions {
6161
color: true,
62-
anonymized_line_numbers: false,
62+
..Default::default()
6363
},
6464
};
6565

examples/expected_type.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use annotate_snippets::{
2-
display_list::DisplayList,
2+
display_list::{DisplayList, FormatOptions},
33
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
44
};
55

@@ -24,7 +24,7 @@ fn main() {
2424
SourceAnnotation {
2525
label: "".to_string(),
2626
annotation_type: AnnotationType::Error,
27-
range: (208, 210),
27+
range: (205, 207),
2828
},
2929
SourceAnnotation {
3030
label: "while parsing this struct".to_string(),
@@ -33,7 +33,10 @@ fn main() {
3333
},
3434
],
3535
}],
36-
opt: Default::default(),
36+
opt: FormatOptions {
37+
color: true,
38+
..Default::default()
39+
},
3740
};
3841

3942
let dl = DisplayList::from(snippet);

examples/footer.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use annotate_snippets::{
2-
display_list::DisplayList,
2+
display_list::{DisplayList, FormatOptions},
33
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
44
};
55

@@ -30,7 +30,10 @@ fn main() {
3030
annotation_type: AnnotationType::Error,
3131
}],
3232
}],
33-
opt: Default::default(),
33+
opt: FormatOptions {
34+
color: true,
35+
..Default::default()
36+
},
3437
};
3538

3639
let dl = DisplayList::from(snippet);

examples/format.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use annotate_snippets::{
2-
display_list::DisplayList,
2+
display_list::{DisplayList, FormatOptions},
33
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
44
};
55

@@ -41,7 +41,7 @@ fn main() {
4141
SourceAnnotation {
4242
label: "expected enum `std::option::Option`".to_string(),
4343
annotation_type: AnnotationType::Error,
44-
range: (23, 745),
44+
range: (26, 724),
4545
},
4646
],
4747
}],
@@ -51,7 +51,10 @@ fn main() {
5151
annotation_type: AnnotationType::Error,
5252
}),
5353
footer: vec![],
54-
opt: Default::default(),
54+
opt: FormatOptions {
55+
color: true,
56+
..Default::default()
57+
},
5558
};
5659

5760
let dl = DisplayList::from(snippet);

examples/multislice.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use annotate_snippets::{
2-
display_list::DisplayList,
2+
display_list::{DisplayList, FormatOptions},
33
snippet::{Annotation, AnnotationType, Slice, Snippet},
44
};
55

@@ -27,7 +27,10 @@ fn main() {
2727
annotations: vec![],
2828
},
2929
],
30-
opt: Default::default(),
30+
opt: FormatOptions {
31+
color: true,
32+
..Default::default()
33+
},
3134
};
3235

3336
let dl = DisplayList::from(snippet);

src/display_list/mod.rs

+1-88
Original file line numberDiff line numberDiff line change
@@ -27,97 +27,10 @@
2727
//! are `Source` lines.
2828
//!
2929
//! `DisplayList` does not store column alignment information, and those are
30-
//! only calculated by the `DisplayListFormatter` using information such as
30+
//! only calculated by the implementation of `std::fmt::Display` using information such as
3131
//! styling.
3232
//!
3333
//! The above snippet has been built out of the following structure:
34-
//!
35-
//! ```rust,ignore
36-
//! use annotate_snippets::display_list::*;
37-
//!
38-
//! let dl = DisplayList {
39-
//! body: vec![
40-
//! DisplayLine::Raw(DisplayRawLine::Annotation {
41-
//! annotation: Annotation {
42-
//! annotation_type: DisplayAnnotationType::Error,
43-
//! id: Some("E0308".to_string()),
44-
//! label: vec![
45-
//! DisplayTextFragment {
46-
//! content: "mismatched types".to_string(),
47-
//! style: DisplayTextStyle::Regular,
48-
//! }
49-
//! ]
50-
//! },
51-
//! source_aligned: false,
52-
//! continuation: false,
53-
//! }),
54-
//! DisplayLine::Raw(DisplayRawLine::Origin {
55-
//! path: "src/format.rs".to_string(),
56-
//! pos: Some((51, 5)),
57-
//! header_type: DisplayHeaderType::Initial,
58-
//! }),
59-
//! DisplayLine::Source {
60-
//! lineno: Some(151),
61-
//! inline_marks: vec![
62-
//! DisplayMark {
63-
//! mark_type: DisplayMarkType::AnnotationStart,
64-
//! annotation_type: DisplayAnnotationType::Error,
65-
//! }
66-
//! ],
67-
//! line: DisplaySourceLine::Content {
68-
//! text: " fn test() -> String {".to_string(),
69-
//! range: (0, 24)
70-
//! }
71-
//! },
72-
//! DisplayLine::Source {
73-
//! lineno: Some(152),
74-
//! inline_marks: vec![
75-
//! DisplayMark {
76-
//! mark_type: DisplayMarkType::AnnotationThrough,
77-
//! annotation_type: DisplayAnnotationType::Error,
78-
//! }
79-
//! ],
80-
//! line: DisplaySourceLine::Content {
81-
//! text: " return \"test\";".to_string(),
82-
//! range: (25, 46)
83-
//! }
84-
//! },
85-
//! DisplayLine::Source {
86-
//! lineno: Some(153),
87-
//! inline_marks: vec![
88-
//! DisplayMark {
89-
//! mark_type: DisplayMarkType::AnnotationThrough,
90-
//! annotation_type: DisplayAnnotationType::Error,
91-
//! }
92-
//! ],
93-
//! line: DisplaySourceLine::Content {
94-
//! text: " }".to_string(),
95-
//! range: (47, 51)
96-
//! }
97-
//! },
98-
//! DisplayLine::Source {
99-
//! lineno: None,
100-
//! inline_marks: vec![],
101-
//! line: DisplaySourceLine::Annotation {
102-
//! annotation: Annotation {
103-
//! annotation_type: DisplayAnnotationType::Error,
104-
//! id: None,
105-
//! label: vec![
106-
//! DisplayTextFragment {
107-
//! content: "expected `String`, for `&str`.".to_string(),
108-
//! style: DisplayTextStyle::Regular,
109-
//! }
110-
//! ]
111-
//! },
112-
//! range: (3, 4),
113-
//! annotation_type: DisplayAnnotationType::Error,
114-
//! annotation_part: DisplayAnnotationPart::MultilineEnd,
115-
//! }
116-
//!
117-
//! }
118-
//! ]
119-
//! };
120-
//! ```
12134
mod from_snippet;
12235
mod structs;
12336

0 commit comments

Comments
 (0)