File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -123,14 +123,14 @@ pub struct TextBytesIterator<'a> {
123
123
impl < ' a > core:: iter:: Iterator for TextBytesIterator < ' a > {
124
124
type Item = u8 ;
125
125
fn next ( & mut self ) -> Option < Self :: Item > {
126
+ while !self . finished ( ) && self . value ( ) == 0 {
127
+ self . advance ( ) ;
128
+ }
126
129
if self . finished ( ) {
127
130
return None ;
128
131
}
129
132
let ret = Some ( self . value ( ) ) ;
130
133
self . advance ( ) ;
131
- while !self . finished ( ) && self . value ( ) == 0 {
132
- self . advance ( ) ;
133
- }
134
134
ret
135
135
}
136
136
@@ -143,7 +143,7 @@ impl<'a> core::iter::FusedIterator for TextBytesIterator<'a> {}
143
143
144
144
impl < ' a > TextBytesIterator < ' a > {
145
145
fn finished ( & self ) -> bool {
146
- self . buffer . len ( ) / 4 <= self . packet_index
146
+ self . packet_index == self . buffer . len ( ) / 4 - 1 && self . byte_index == 11
147
147
}
148
148
fn advance ( & mut self ) {
149
149
self . byte_index += 1 ;
Original file line number Diff line number Diff line change @@ -389,6 +389,16 @@ mod tests {
389
389
)
390
390
}
391
391
392
+ #[ test]
393
+ fn read_empty_text_bytes ( ) {
394
+ assert_eq ! (
395
+ UnknownMetadataText :: <std:: vec:: Vec <u32 >>:: new( )
396
+ . text_bytes( )
397
+ . collect:: <std:: vec:: Vec <u8 >>( ) ,
398
+ std:: vec![ ] ,
399
+ )
400
+ }
401
+
392
402
#[ test]
393
403
#[ cfg( feature = "std" ) ]
394
404
fn read_string ( ) {
You can’t perform that action at this time.
0 commit comments