Skip to content

Commit ffaa5c9

Browse files
committed
Document that std::io::BufReader discards contents on drop
Resolves #55546
1 parent 07d3508 commit ffaa5c9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libstd/io/buffered.rs

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ use crate::memchr;
2121
/// times. It also provides no advantage when reading from a source that is
2222
/// already in memory, like a `Vec<u8>`.
2323
///
24+
/// When the `BufReader` is dropped, the contents of its buffer will be
25+
/// discarded. Creating multiple instances of a `BufReader` on the same
26+
/// stream can cause data loss.
27+
///
2428
/// [`Read`]: ../../std/io/trait.Read.html
2529
/// [`TcpStream::read`]: ../../std/net/struct.TcpStream.html#method.read
2630
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html

0 commit comments

Comments
 (0)