File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,11 @@ impl MemReader {
111
111
}
112
112
}
113
113
114
+ /// Tests whether this reader has read all bytes in its buffer.
115
+ ///
116
+ /// If `true`, then this will no longer return bytes from `read`.
117
+ pub fn eof ( & self ) -> bool { self . pos == self . buf . len ( ) }
118
+
114
119
/// Acquires an immutable reference to the underlying buffer of this
115
120
/// `MemReader`.
116
121
///
@@ -124,7 +129,7 @@ impl MemReader {
124
129
125
130
impl Reader for MemReader {
126
131
fn read ( & mut self , buf : & mut [ u8 ] ) -> Option < uint > {
127
- if self . pos == self . buf . len ( ) { return None }
132
+ if self . eof ( ) { return None }
128
133
129
134
let write_len = min ( buf. len ( ) , self . buf . len ( ) - self . pos ) ;
130
135
{
@@ -216,11 +221,16 @@ impl<'a> BufReader<'a> {
216
221
pos : 0
217
222
}
218
223
}
224
+
225
+ /// Tests whether this reader has read all bytes in its buffer.
226
+ ///
227
+ /// If `true`, then this will no longer return bytes from `read`.
228
+ pub fn eof ( & self ) -> bool { self . pos == self . buf . len ( ) }
219
229
}
220
230
221
231
impl < ' a > Reader for BufReader < ' a > {
222
232
fn read ( & mut self , buf : & mut [ u8 ] ) -> Option < uint > {
223
- if self . pos == self . buf . len ( ) { return None }
233
+ if self . eof ( ) { return None }
224
234
225
235
let write_len = min ( buf. len ( ) , self . buf . len ( ) - self . pos ) ;
226
236
{
You can’t perform that action at this time.
0 commit comments