@@ -364,10 +364,10 @@ impl<R: Seek> Seek for BufReader<R> {
364
364
/// times. It also provides no advantage when writing to a destination that is
365
365
/// in memory, like a `Vec<u8>`.
366
366
///
367
- /// When the `BufWriter` is dropped, the contents of its buffer will be written
368
- /// out. However, any errors that happen in the process of flushing the buffer
369
- /// when the writer is dropped will be ignored. Code that wishes to handle such
370
- /// errors must manually call [`flush`] before the writer is dropped .
367
+ /// It is critical to call [`flush`] before `BufWriter` is dropped. Though
368
+ /// dropping will attempt to flush the the contents of the buffer, any errors
369
+ /// that happen in the process will be ignored. Calling ['flush'] ensures that
370
+ /// the buffer is empty and all errors have been observed .
371
371
///
372
372
/// # Examples
373
373
///
@@ -398,11 +398,12 @@ impl<R: Seek> Seek for BufReader<R> {
398
398
/// for i in 0..10 {
399
399
/// stream.write(&[i+1]).unwrap();
400
400
/// }
401
+ /// stream.flush().unwrap();
401
402
/// ```
402
403
///
403
404
/// By wrapping the stream with a `BufWriter`, these ten writes are all grouped
404
- /// together by the buffer, and will all be written out in one system call when
405
- /// the `stream` is dropped .
405
+ /// together by the buffer and will all be written out in one system call when
406
+ /// the `stream` is flushed .
406
407
///
407
408
/// [`Write`]: ../../std/io/trait.Write.html
408
409
/// [`TcpStream::write`]: ../../std/net/struct.TcpStream.html#method.write
0 commit comments