File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
Original file line number Diff line number Diff line change 7
7
8
8
#[ derive( Debug ) ]
9
9
pub struct Parser < ' a > {
10
- // Splitting the fields and manually reconstructing the item parser allows
11
- // avoiding troubles with shared mutable references, lifetimes etc.
12
- data : & ' a [ u8 ] ,
13
- index : Cell < usize > ,
10
+ // Manually reconstructing the item parser allows avoiding troubles with shared mutable
11
+ // references, lifetimes etc.
12
+ data : Cell < & ' a [ u8 ] > ,
14
13
}
15
14
16
15
impl < ' a > Parser < ' a > {
@@ -74,14 +73,14 @@ impl<'a, 'p> Iterator for StackFrame<'a, 'p> {
74
73
75
74
fn next ( & mut self ) -> Option < Self :: Item > {
76
75
let mut it = super :: Parser {
77
- data : self . inner . data . get ( self . inner . index . get ( ) .. ) ? ,
76
+ data : self . inner . data . get ( ) ,
78
77
} ;
79
78
loop {
80
79
let item = match it. next ( ) ? {
81
80
Ok ( e) => e,
82
81
Err ( e) => return Some ( Err ( ParseError :: from_item ( e) ) ) ,
83
82
} ;
84
- self . inner . index . set ( self . inner . data . len ( ) - it. data . len ( ) ) ;
83
+ self . inner . data . set ( it. data ) ;
85
84
match item {
86
85
Item :: Collection ( ty) => break Some ( Ok ( Value :: Collection ( ty) ) ) ,
87
86
Item :: EndCollection => break Some ( Ok ( Value :: EndCollection ) ) ,
@@ -243,10 +242,7 @@ impl Field {
243
242
}
244
243
245
244
pub fn parse ( data : & [ u8 ] ) -> Parser < ' _ > {
246
- Parser {
247
- data,
248
- index : Default :: default ( ) ,
249
- }
245
+ Parser { data : data. into ( ) }
250
246
}
251
247
252
248
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments