1
1
use serde:: { Deserialize , Deserializer , Serialize } ;
2
2
use std:: ops:: Range ;
3
3
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 } ;
7
5
8
6
#[ derive( Deserialize ) ]
9
7
pub struct Fixture < ' a > {
@@ -105,9 +103,9 @@ pub struct SliceDef<'a> {
105
103
pub line_start : usize ,
106
104
#[ serde( borrow) ]
107
105
pub origin : Option < & ' a str > ,
108
- #[ serde( deserialize_with = "deserialize_source_annotations " ) ]
106
+ #[ serde( deserialize_with = "deserialize_annotations " ) ]
109
107
#[ serde( borrow) ]
110
- pub annotations : Vec < SourceAnnotation < ' a > > ,
108
+ pub annotations : Vec < Annotation < ' a > > ,
111
109
#[ serde( default ) ]
112
110
pub fold : bool ,
113
111
}
@@ -132,31 +130,29 @@ impl<'a> From<SliceDef<'a>> for Slice<'a> {
132
130
}
133
131
}
134
132
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 >
138
134
where
139
135
D : Deserializer < ' de > ,
140
136
{
141
137
#[ derive( Deserialize ) ]
142
- struct Wrapper < ' a > ( #[ serde( borrow) ] SourceAnnotationDef < ' a > ) ;
138
+ struct Wrapper < ' a > ( #[ serde( borrow) ] AnnotationDef < ' a > ) ;
143
139
144
140
let v = Vec :: deserialize ( deserializer) ?;
145
141
Ok ( v. into_iter ( ) . map ( |Wrapper ( a) | a. into ( ) ) . collect ( ) )
146
142
}
147
143
148
144
#[ derive( Serialize , Deserialize ) ]
149
- pub struct SourceAnnotationDef < ' a > {
145
+ pub struct AnnotationDef < ' a > {
150
146
pub range : Range < usize > ,
151
147
#[ serde( borrow) ]
152
148
pub label : & ' a str ,
153
149
#[ serde( with = "LevelDef" ) ]
154
150
pub level : Level ,
155
151
}
156
152
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 {
160
156
range,
161
157
label,
162
158
level,
0 commit comments