@@ -35,49 +35,47 @@ Usage
3535
3636``` rust
3737use annotate_snippets :: {
38- display_list :: DisplayList ,
39- formatter :: DisplayListFormatter ,
38+ display_list :: {DisplayList , FormatOptions },
4039 snippet :: {Annotation , AnnotationType , Slice , Snippet , SourceAnnotation },
4140};
4241
4342fn main () {
4443 let snippet = Snippet {
4544 title : Some (Annotation {
46- label : Some (" expected type, found `22`" . to_string () ),
45+ label : Some (" expected type, found `22`" ),
4746 id : None ,
4847 annotation_type : AnnotationType :: Error ,
4948 }),
5049 footer : vec! [],
51- slices : vec! [
52- Slice {
53- source : r # "
54- This is an example
55- content of the slice
56- which will be annotated
57- with the list of annotations below.
58- " # . to_string () ,
59- line_start : 26 ,
60- origin : Some ( " examples/example.txt " . to_string ()),
61- fold : false ,
62- annotations : vec! [
63- SourceAnnotation {
64- label : " Example error annotation " . to_string () ,
65- annotation_type : AnnotationType :: Error ,
66- range : ( 13 , 18 ) ,
67- } ,
68- SourceAnnotation {
69- label : " and here's a warning " . to_string () ,
70- annotation_type : AnnotationType :: Warning ,
71- range : ( 34 , 50 ) ,
72- },
73- ] ,
74- },
75- ] ,
50+ slices : vec! [Slice {
51+ source : r # " annotations: vec![SourceAnnotation {
52+ label: "expected struct `annotate_snippets::snippet::Slice`, found reference "
53+ ,
54+ range: <22, 25>, " # ,
55+ line_start : 26 ,
56+ origin : Some ( " examples/footer.rs " ),
57+ fold : true ,
58+ annotations : vec! [
59+ SourceAnnotation {
60+ label : "" ,
61+ annotation_type : AnnotationType :: Error ,
62+ range : ( 205 , 207 ),
63+ } ,
64+ SourceAnnotation {
65+ label : " while parsing this struct " ,
66+ annotation_type : AnnotationType :: Info ,
67+ range : ( 34 , 50 ),
68+ } ,
69+ ] ,
70+ }] ,
71+ opt : FormatOptions {
72+ color : true ,
73+ .. Default :: default ()
74+ } ,
7675 };
7776
7877 let dl = DisplayList :: from (snippet );
79- let dlf = DisplayListFormatter :: new (true , false );
80- println! (" {}" , dlf . format (& dl ));
78+ println! (" {}" , dl );
8179}
8280```
8381
0 commit comments