This repository was archived by the owner on Aug 15, 2021. It is now read-only.
File tree 2 files changed +11
-12
lines changed
2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -280,16 +280,16 @@ where
280
280
}
281
281
282
282
fn try_parse_u128 ( & mut self ) -> Result < Option < u128 > > {
283
- // ^ Only *try* parse because the value could be a non-u128 byte array .
283
+ // ^ Only *try* parse because the value could be a non-u128 bytestring .
284
284
let desc = match self . peek ( ) ? {
285
285
Some ( desc) => desc,
286
286
None => return Ok ( None ) ,
287
287
} ;
288
288
let ty = desc >> 5 ;
289
289
if ty != 2 {
290
- return Ok ( None ) ;
290
+ return Ok ( None ) ; // not a bytestring
291
291
}
292
- let len = desc & 0x1fu8 ;
292
+ let len = desc & 0x1f ;
293
293
if len > 16 {
294
294
return Ok ( None ) ;
295
295
}
@@ -730,7 +730,7 @@ where
730
730
Some ( value) => visitor. visit_i128 ( -1 - value as i128 ) ,
731
731
None => self . parse_value ( visitor) ,
732
732
} ,
733
- 0xc1 | 0xc4 ..=0xd7 => self . parse_value ( visitor) ,
733
+ 0xc0 | 0xc1 | 0xc4 ..=0xd7 => self . parse_value ( visitor) ,
734
734
0xd8 => {
735
735
self . parse_u8 ( ) ?;
736
736
self . parse_value ( visitor)
@@ -770,8 +770,7 @@ where
770
770
}
771
771
0xfc ..=0xfe => Err ( self . error ( ErrorCode :: UnassignedCode ) ) ,
772
772
0xff => Err ( self . error ( ErrorCode :: UnexpectedCode ) ) ,
773
-
774
- _ => unreachable ! ( ) ,
773
+ _ => unreachable ! ( ) // Remove this once minimum supported rustc version is 1.33.0.
775
774
}
776
775
}
777
776
}
Original file line number Diff line number Diff line change @@ -183,13 +183,13 @@ where
183
183
if len <= 8 {
184
184
self . write_u64 ( tag - 2 , value as u64 )
185
185
} else {
186
+ let mut buf = [ 0u8 ; 2 + 16 ] ;
187
+ BigEndian :: write_u128 ( & mut buf[ 2 ..] , value) ;
188
+ let hdr_offset = 16 - len as usize ;
189
+ buf[ hdr_offset] = 6 << 5 | tag;
190
+ buf[ hdr_offset + 1 ] = 2 << 5 | len as u8 ;
186
191
self . writer
187
- . write_all ( & [ 6 << 5 | tag, 2 << 5 | len as u8 ] )
188
- . map_err ( |e| e. into ( ) ) ?;
189
- let mut buf = [ 0u8 ; 16 ] ;
190
- BigEndian :: write_u128 ( & mut buf, value) ;
191
- self . writer
192
- . write_all ( & buf[ ( 16 - len) as usize ..] )
192
+ . write_all ( & buf[ hdr_offset..] )
193
193
. map_err ( |e| e. into ( ) )
194
194
}
195
195
}
You can’t perform that action at this time.
0 commit comments