Skip to content

Commit 2e08306

Browse files
committed
Rollup merge of #23432 - mzabaluev:io-into-inner-doc, r=alexcrichton
Resolves #23386.
2 parents fad4c38 + e3aefaa commit 2e08306

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/libstd/io/buffered.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,16 @@ impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug {
118118
/// `BufWriter` keeps an in memory buffer of data and writes it to the
119119
/// underlying `Write` in large, infrequent batches.
120120
///
121-
/// This writer will be flushed when it is dropped.
121+
/// The buffer will be written out when the writer is dropped.
122122
#[stable(feature = "rust1", since = "1.0.0")]
123123
pub struct BufWriter<W> {
124124
inner: Option<W>,
125125
buf: Vec<u8>,
126126
}
127127

128-
/// An error returned by `into_inner` which indicates whether a flush error
129-
/// happened or not.
128+
/// An error returned by `into_inner` which combines an error that
129+
/// happened while writing out the buffer, and the buffered writer object
130+
/// which may be used to recover from the condition.
130131
#[derive(Debug)]
131132
#[stable(feature = "rust1", since = "1.0.0")]
132133
pub struct IntoInnerError<W>(W, Error);
@@ -155,7 +156,7 @@ impl<W: Write> BufWriter<W> {
155156
match self.inner.as_mut().unwrap().write(&self.buf[written..]) {
156157
Ok(0) => {
157158
ret = Err(Error::new(ErrorKind::WriteZero,
158-
"failed to flush", None));
159+
"failed to write the buffered data", None));
159160
break;
160161
}
161162
Ok(n) => written += n,
@@ -190,7 +191,7 @@ impl<W: Write> BufWriter<W> {
190191

191192
/// Unwraps this `BufWriter`, returning the underlying writer.
192193
///
193-
/// The buffer is flushed before returning the writer.
194+
/// The buffer is written out before returning the writer.
194195
#[stable(feature = "rust1", since = "1.0.0")]
195196
pub fn into_inner(mut self) -> Result<W, IntoInnerError<BufWriter<W>>> {
196197
match self.flush_buf() {
@@ -239,14 +240,14 @@ impl<W: Write> Drop for BufWriter<W> {
239240
impl<W> IntoInnerError<W> {
240241
/// Returns the error which caused the call to `into_inner` to fail.
241242
///
242-
/// This error was returned when attempting to flush the internal buffer.
243+
/// This error was returned when attempting to write the internal buffer.
243244
#[stable(feature = "rust1", since = "1.0.0")]
244245
pub fn error(&self) -> &Error { &self.1 }
245246

246-
/// Returns the underlying `BufWriter` instance which generated the error.
247+
/// Returns the buffered writer instance which generated the error.
247248
///
248-
/// The returned object can be used to retry a flush or re-inspect the
249-
/// buffer.
249+
/// The returned object can be used for error recovery, such as
250+
/// re-inspecting the buffer.
250251
#[stable(feature = "rust1", since = "1.0.0")]
251252
pub fn into_inner(self) -> W { self.0 }
252253
}
@@ -273,7 +274,7 @@ impl<W> fmt::Display for IntoInnerError<W> {
273274
/// Wraps a Writer and buffers output to it, flushing whenever a newline
274275
/// (`0x0a`, `'\n'`) is detected.
275276
///
276-
/// This writer will be flushed when it is dropped.
277+
/// The buffer will be written out when the writer is dropped.
277278
#[stable(feature = "rust1", since = "1.0.0")]
278279
pub struct LineWriter<W> {
279280
inner: BufWriter<W>,
@@ -307,7 +308,7 @@ impl<W: Write> LineWriter<W> {
307308

308309
/// Unwraps this `LineWriter`, returning the underlying writer.
309310
///
310-
/// The internal buffer is flushed before returning the writer.
311+
/// The internal buffer is written out before returning the writer.
311312
#[stable(feature = "rust1", since = "1.0.0")]
312313
pub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>> {
313314
self.inner.into_inner().map_err(|IntoInnerError(buf, e)| {
@@ -364,7 +365,7 @@ impl<W: Read> Read for InternalBufWriter<W> {
364365
/// call. A `BufStream` keeps in memory buffers of data, making large,
365366
/// infrequent calls to `read` and `write` on the underlying `Read+Write`.
366367
///
367-
/// The output half will be flushed when this stream is dropped.
368+
/// The output buffer will be written out when this stream is dropped.
368369
#[stable(feature = "rust1", since = "1.0.0")]
369370
pub struct BufStream<S> {
370371
inner: BufReader<InternalBufWriter<S>>
@@ -410,8 +411,8 @@ impl<S: Read + Write> BufStream<S> {
410411

411412
/// Unwraps this `BufStream`, returning the underlying stream.
412413
///
413-
/// The internal buffer is flushed before returning the stream. Any leftover
414-
/// data in the read buffer is lost.
414+
/// The internal write buffer is written out before returning the stream.
415+
/// Any leftover data in the read buffer is lost.
415416
#[stable(feature = "rust1", since = "1.0.0")]
416417
pub fn into_inner(self) -> Result<S, IntoInnerError<BufStream<S>>> {
417418
let BufReader { inner: InternalBufWriter(w), buf } = self.inner;

0 commit comments

Comments
 (0)