@@ -71,7 +71,7 @@ pub trait ReaderUtil {
71
71
/// Raises the same conditions as the `read` method, for
72
72
/// each call to its `.next()` method.
73
73
/// Ends the iteration if the condition is handled.
74
- fn bytes ( self ) -> Bytes < Self > ;
74
+ fn bytes ( self ) -> ByteIterator < Self > ;
75
75
76
76
}
77
77
@@ -349,30 +349,36 @@ impl<T: Reader> ReaderUtil for T {
349
349
return buf;
350
350
}
351
351
352
- fn bytes ( self ) -> Bytes < T > {
353
- Bytes { reader : self }
352
+ fn bytes ( self ) -> ByteIterator < T > {
353
+ ByteIterator { reader : self }
354
354
}
355
355
}
356
356
357
357
/// An iterator that reads a single byte on each iteration,
358
- /// until EOF.
358
+ /// until `.read_byte()` returns `None`.
359
+ ///
360
+ /// # Notes about the Iteration Protocol
361
+ ///
362
+ /// The `ByteIterator` may yield `None` and thus terminate
363
+ /// an iteration, but continue to yield elements if iteration
364
+ /// is attempted again.
359
365
///
360
366
/// # Failure
361
367
///
362
368
/// Raises the same conditions as the `read` method, for
363
369
/// each call to its `.next()` method.
364
- /// Ends the iteration if the condition is handled.
365
- pub struct Bytes < T > {
370
+ /// Yields `None` if the condition is handled.
371
+ pub struct ByteIterator < T > {
366
372
priv reader : T ,
367
373
}
368
374
369
- impl < R > Decorator < R > for Bytes < R > {
375
+ impl < R > Decorator < R > for ByteIterator < R > {
370
376
fn inner ( self ) -> R { self . reader }
371
377
fn inner_ref < ' a > ( & ' a self ) -> & ' a R { & self . reader }
372
378
fn inner_mut_ref < ' a > ( & ' a mut self ) -> & ' a mut R { & mut self . reader }
373
379
}
374
380
375
- impl < ' self , R : Reader > Iterator < u8 > for Bytes < R > {
381
+ impl < ' self , R : Reader > Iterator < u8 > for ByteIterator < R > {
376
382
#[ inline]
377
383
fn next ( & mut self ) -> Option < u8 > {
378
384
self . reader . read_byte ( )
0 commit comments