11use serde:: { Deserialize , Deserializer , Serialize } ;
22use std:: ops:: Range ;
33
4- use annotate_snippets:: {
5- renderer:: Margin , Label , Level , Renderer , Slice , Snippet , SourceAnnotation ,
6- } ;
4+ use annotate_snippets:: { renderer:: Margin , Annotation , Label , Level , Renderer , Slice , Snippet } ;
75
86#[ derive( Deserialize ) ]
97pub struct Fixture < ' a > {
@@ -105,9 +103,9 @@ pub struct SliceDef<'a> {
105103 pub line_start : usize ,
106104 #[ serde( borrow) ]
107105 pub origin : Option < & ' a str > ,
108- #[ serde( deserialize_with = "deserialize_source_annotations " ) ]
106+ #[ serde( deserialize_with = "deserialize_annotations " ) ]
109107 #[ serde( borrow) ]
110- pub annotations : Vec < SourceAnnotation < ' a > > ,
108+ pub annotations : Vec < Annotation < ' a > > ,
111109 #[ serde( default ) ]
112110 pub fold : bool ,
113111}
@@ -132,31 +130,29 @@ impl<'a> From<SliceDef<'a>> for Slice<'a> {
132130 }
133131}
134132
135- fn deserialize_source_annotations < ' de , D > (
136- deserializer : D ,
137- ) -> Result < Vec < SourceAnnotation < ' de > > , D :: Error >
133+ fn deserialize_annotations < ' de , D > ( deserializer : D ) -> Result < Vec < Annotation < ' de > > , D :: Error >
138134where
139135 D : Deserializer < ' de > ,
140136{
141137 #[ derive( Deserialize ) ]
142- struct Wrapper < ' a > ( #[ serde( borrow) ] SourceAnnotationDef < ' a > ) ;
138+ struct Wrapper < ' a > ( #[ serde( borrow) ] AnnotationDef < ' a > ) ;
143139
144140 let v = Vec :: deserialize ( deserializer) ?;
145141 Ok ( v. into_iter ( ) . map ( |Wrapper ( a) | a. into ( ) ) . collect ( ) )
146142}
147143
148144#[ derive( Serialize , Deserialize ) ]
149- pub struct SourceAnnotationDef < ' a > {
145+ pub struct AnnotationDef < ' a > {
150146 pub range : Range < usize > ,
151147 #[ serde( borrow) ]
152148 pub label : & ' a str ,
153149 #[ serde( with = "LevelDef" ) ]
154150 pub level : Level ,
155151}
156152
157- impl < ' a > From < SourceAnnotationDef < ' a > > for SourceAnnotation < ' a > {
158- fn from ( val : SourceAnnotationDef < ' a > ) -> Self {
159- let SourceAnnotationDef {
153+ impl < ' a > From < AnnotationDef < ' a > > for Annotation < ' a > {
154+ fn from ( val : AnnotationDef < ' a > ) -> Self {
155+ let AnnotationDef {
160156 range,
161157 label,
162158 level,
0 commit comments