File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
library/alloc/src/io/buffered Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,24 @@ impl<W: Write> LineWriter<W> {
155
155
self . inner . get_mut ( )
156
156
}
157
157
158
+ /// Returns a reference to the internally buffered data.
159
+ ///
160
+ /// # Examples
161
+ ///
162
+ /// ```no_run
163
+ /// use std::io::LineWriter;
164
+ /// use std::net::TcpStream;
165
+ ///
166
+ /// let buf_writer = LineWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap());
167
+ ///
168
+ /// // See how many bytes are currently buffered
169
+ /// let bytes_buffered = buf_writer.buffer().len();
170
+ /// ```
171
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
172
+ pub fn buffer ( & self ) -> & [ u8 ] {
173
+ & self . inner . buffer ( )
174
+ }
175
+
158
176
/// Unwraps this `LineWriter`, returning the underlying writer.
159
177
///
160
178
/// The internal buffer is written out before returning the writer.
You can’t perform that action at this time.
0 commit comments