File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -525,6 +525,25 @@ impl<W: Write> BufWriter<W> {
525
525
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
526
526
pub fn get_mut ( & mut self ) -> & mut W { self . inner . as_mut ( ) . unwrap ( ) }
527
527
528
+ /// Returns a reference to the internally buffered data.
529
+ ///
530
+ /// # Examples
531
+ ///
532
+ /// ```no_run
533
+ /// # #![feature(bufreader_buffer)]
534
+ /// use std::io::BufWriter;
535
+ /// use std::net::TcpStream;
536
+ ///
537
+ /// let mut buf_writer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap());
538
+ ///
539
+ /// // See how many bytes are currently buffered
540
+ /// let bytes_buffered = buf_writer.buffer().len();
541
+ /// ```
542
+ #[ unstable( feature = "bufreader_buffer" , issue = "45323" ) ]
543
+ pub fn buffer ( & self ) -> & [ u8 ] {
544
+ & self . buf [ ..]
545
+ }
546
+
528
547
/// Unwraps this `BufWriter`, returning the underlying writer.
529
548
///
530
549
/// The buffer is written out before returning the writer.
You can’t perform that action at this time.
0 commit comments