@@ -2250,24 +2250,18 @@ fn skip_until<R: BufRead + ?Sized>(r: &mut R, delim: u8) -> Result<usize> {
22502250/// ```
22512251#[ stable( feature = "rust1" , since = "1.0.0" ) ]
22522252pub trait BufRead : Read {
2253- /// Returns the contents of the internal buffer, filling it with more data
2254- /// from the inner reader if it is empty.
2253+ /// Returns the contents of the internal buffer, filling it with more data, via Read methods, if empty.
22552254 ///
2256- /// This function is a lower-level call. It needs to be paired with the
2257- /// [`consume`] method to function properly. When calling this
2258- /// method, none of the contents will be "read" in the sense that later
2259- /// calling `read` may return the same contents. As such, [`consume`] must
2260- /// be called with the number of bytes that are consumed from this buffer to
2261- /// ensure that the bytes are never returned twice.
2255+ /// This is a lower-level method and is meant to be used together with [`consume`],
2256+ /// which can be used to mark bytes that should not be returned by subsequent calls to `read`.
22622257 ///
22632258 /// [`consume`]: BufRead::consume
22642259 ///
2265- /// An empty buffer returned indicates that the stream has reached EOF.
2260+ /// Returns an empty buffer to indicate that the stream has reached EOF.
22662261 ///
22672262 /// # Errors
22682263 ///
2269- /// This function will return an I/O error if the underlying reader was
2270- /// read, but returned an error.
2264+ /// Passes on I/O errors from Read.
22712265 ///
22722266 /// # Examples
22732267 ///
@@ -2285,26 +2279,21 @@ pub trait BufRead: Read {
22852279 /// // work with buffer
22862280 /// println!("{buffer:?}");
22872281 ///
2288- /// // ensure the bytes we worked with aren't returned again later
2282+ /// // mark the bytes we worked with as read
22892283 /// let length = buffer.len();
22902284 /// stdin.consume(length);
22912285 /// # std::io::Result::Ok(())
22922286 /// ```
22932287 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
22942288 fn fill_buf ( & mut self ) -> Result < & [ u8 ] > ;
22952289
2296- /// Tells this buffer that `amt` bytes have been consumed from the buffer,
2297- /// so they should no longer be returned in calls to `read` .
2290+ /// Marks the given `amount` of additional bytes from the internal buffer as having been read.
2291+ /// Subsequent calls to `read` return bytes that have not yet been so marked .
22982292 ///
2299- /// This function is a lower-level call. It needs to be paired with the
2300- /// [`fill_buf`] method to function properly. This function does
2301- /// not perform any I/O, it simply informs this object that some amount of
2302- /// its buffer, returned from [`fill_buf`], has been consumed and should
2303- /// no longer be returned. As such, this function may do odd things if
2304- /// [`fill_buf`] isn't called before calling it.
2293+ /// This is a lower-level method and is meant to be used together with [`fill_buf`],
2294+ /// which can be used to fill the internal buffer via Read methods.
23052295 ///
2306- /// The `amt` must be `<=` the number of bytes in the buffer returned by
2307- /// [`fill_buf`].
2296+ /// It is a logic error if `amount` exceeds the number of unread bytes in the internal buffer.
23082297 ///
23092298 /// # Examples
23102299 ///
@@ -2313,9 +2302,9 @@ pub trait BufRead: Read {
23132302 ///
23142303 /// [`fill_buf`]: BufRead::fill_buf
23152304 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2316- fn consume ( & mut self , amt : usize ) ;
2305+ fn consume ( & mut self , amount : usize ) ;
23172306
2318- /// Checks if the underlying `Read` has any data left to be read.
2307+ /// Checks if there is any data left to be ` read` .
23192308 ///
23202309 /// This function may fill the buffer to check for data,
23212310 /// so this functions returns `Result<bool>`, not `bool`.
@@ -2324,6 +2313,10 @@ pub trait BufRead: Read {
23242313 /// returned slice is empty (which means that there is no data left,
23252314 /// since EOF is reached).
23262315 ///
2316+ /// # Errors
2317+ ///
2318+ /// Passes on I/O errors from Read.
2319+ ///
23272320 /// Examples
23282321 ///
23292322 /// ```
0 commit comments