From ffaa5c904e6de9cf15c44adfa43a56f046c28c42 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Wed, 27 Mar 2019 22:11:13 -0400 Subject: Document that `std::io::BufReader` discards contents on drop Resolves #55546 --- src/libstd/io/buffered.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/libstd/io') diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 4668e3ec7ea..487706b05bb 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -21,6 +21,10 @@ use crate::memchr; /// times. It also provides no advantage when reading from a source that is /// already in memory, like a `Vec`. /// +/// When the `BufReader` is dropped, the contents of its buffer will be +/// discarded. Creating multiple instances of a `BufReader` on the same +/// stream can cause data loss. +/// /// [`Read`]: ../../std/io/trait.Read.html /// [`TcpStream::read`]: ../../std/net/struct.TcpStream.html#method.read /// [`TcpStream`]: ../../std/net/struct.TcpStream.html -- cgit 1.4.1-3-g733a5 From e1e0e53f1624489afd8f086017a599afbef21058 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Wed, 27 Mar 2019 23:01:24 -0400 Subject: Fix link capitalization in documentation of std::io::BufWriter. --- src/libstd/io/buffered.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd/io') diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 4668e3ec7ea..232afcd518c 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -350,7 +350,7 @@ impl Seek for BufReader { /// /// It can be excessively inefficient to work directly with something that /// implements [`Write`]. For example, every call to -/// [`write`][`Tcpstream::write`] on [`TcpStream`] results in a system call. A +/// [`write`][`TcpStream::write`] on [`TcpStream`] results in a system call. A /// `BufWriter` keeps an in-memory buffer of data and writes it to an underlying /// writer in large, infrequent batches. /// @@ -401,7 +401,7 @@ impl Seek for BufReader { /// the `stream` is dropped. /// /// [`Write`]: ../../std/io/trait.Write.html -/// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write +/// [`TcpStream::write`]: ../../std/net/struct.TcpStream.html#method.write /// [`TcpStream`]: ../../std/net/struct.TcpStream.html /// [`flush`]: #method.flush #[stable(feature = "rust1", since = "1.0.0")] -- cgit 1.4.1-3-g733a5