Skip to content

Commit 900c13e

Browse files
author
Marco Conte
committed
enhance the documentation of std::io::BufReader regarding potential data loss
1 parent 2f16be4 commit 900c13e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libstd/io/buffered.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ use crate::memchr;
2424
///
2525
/// When the `BufReader<R>` is dropped, the contents of its buffer will be
2626
/// discarded. Creating multiple instances of a `BufReader<R>` on the same
27-
/// stream can cause data loss.
27+
/// stream can cause data loss, as well as reading from the underlying reader
28+
/// after unwrapping the `BufReader<R>` instance with `BufReader<R>::into_inner()`.
2829
///
2930
/// [`Read`]: ../../std/io/trait.Read.html
3031
/// [`TcpStream::read`]: ../../std/net/struct.TcpStream.html#method.read
@@ -179,7 +180,8 @@ impl<R> BufReader<R> {
179180

180181
/// Unwraps this `BufReader<R>`, returning the underlying reader.
181182
///
182-
/// Note that any leftover data in the internal buffer is lost.
183+
/// Note that any leftover data in the internal buffer is lost. Therefore,
184+
/// a following read from the underlying reader may lead to data loss.
183185
///
184186
/// # Examples
185187
///

0 commit comments

Comments
 (0)