@@ -118,15 +118,16 @@ impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug {
118
118
/// `BufWriter` keeps an in memory buffer of data and writes it to the
119
119
/// underlying `Write` in large, infrequent batches.
120
120
///
121
- /// This writer will be flushed when it is dropped.
121
+ /// The buffer will be written out when the writer is dropped.
122
122
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
123
123
pub struct BufWriter < W > {
124
124
inner : Option < W > ,
125
125
buf : Vec < u8 > ,
126
126
}
127
127
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.
130
131
#[ derive( Debug ) ]
131
132
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
132
133
pub struct IntoInnerError < W > ( W , Error ) ;
@@ -155,7 +156,7 @@ impl<W: Write> BufWriter<W> {
155
156
match self . inner . as_mut ( ) . unwrap ( ) . write ( & self . buf [ written..] ) {
156
157
Ok ( 0 ) => {
157
158
ret = Err ( Error :: new ( ErrorKind :: WriteZero ,
158
- "failed to flush " , None ) ) ;
159
+ "failed to write the buffered data " , None ) ) ;
159
160
break ;
160
161
}
161
162
Ok ( n) => written += n,
@@ -190,7 +191,7 @@ impl<W: Write> BufWriter<W> {
190
191
191
192
/// Unwraps this `BufWriter`, returning the underlying writer.
192
193
///
193
- /// The buffer is flushed before returning the writer.
194
+ /// The buffer is written out before returning the writer.
194
195
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
195
196
pub fn into_inner ( mut self ) -> Result < W , IntoInnerError < BufWriter < W > > > {
196
197
match self . flush_buf ( ) {
@@ -239,14 +240,14 @@ impl<W: Write> Drop for BufWriter<W> {
239
240
impl < W > IntoInnerError < W > {
240
241
/// Returns the error which caused the call to `into_inner` to fail.
241
242
///
242
- /// This error was returned when attempting to flush the internal buffer.
243
+ /// This error was returned when attempting to write the internal buffer.
243
244
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
244
245
pub fn error ( & self ) -> & Error { & self . 1 }
245
246
246
- /// Returns the underlying `BufWriter` instance which generated the error.
247
+ /// Returns the buffered writer instance which generated the error.
247
248
///
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.
250
251
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
251
252
pub fn into_inner ( self ) -> W { self . 0 }
252
253
}
@@ -273,7 +274,7 @@ impl<W> fmt::Display for IntoInnerError<W> {
273
274
/// Wraps a Writer and buffers output to it, flushing whenever a newline
274
275
/// (`0x0a`, `'\n'`) is detected.
275
276
///
276
- /// This writer will be flushed when it is dropped.
277
+ /// The buffer will be written out when the writer is dropped.
277
278
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
278
279
pub struct LineWriter < W > {
279
280
inner : BufWriter < W > ,
@@ -307,7 +308,7 @@ impl<W: Write> LineWriter<W> {
307
308
308
309
/// Unwraps this `LineWriter`, returning the underlying writer.
309
310
///
310
- /// The internal buffer is flushed before returning the writer.
311
+ /// The internal buffer is written out before returning the writer.
311
312
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
312
313
pub fn into_inner ( self ) -> Result < W , IntoInnerError < LineWriter < W > > > {
313
314
self . inner . into_inner ( ) . map_err ( |IntoInnerError ( buf, e) | {
@@ -364,7 +365,7 @@ impl<W: Read> Read for InternalBufWriter<W> {
364
365
/// call. A `BufStream` keeps in memory buffers of data, making large,
365
366
/// infrequent calls to `read` and `write` on the underlying `Read+Write`.
366
367
///
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.
368
369
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
369
370
pub struct BufStream < S > {
370
371
inner : BufReader < InternalBufWriter < S > >
@@ -410,8 +411,8 @@ impl<S: Read + Write> BufStream<S> {
410
411
411
412
/// Unwraps this `BufStream`, returning the underlying stream.
412
413
///
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.
415
416
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
416
417
pub fn into_inner ( self ) -> Result < S , IntoInnerError < BufStream < S > > > {
417
418
let BufReader { inner : InternalBufWriter ( w) , buf } = self . inner ;
0 commit comments