@@ -75,10 +75,14 @@ impl<R: Reader> BufferedReader<R> {
75
75
}
76
76
77
77
/// Gets a reference to the underlying reader.
78
+ pub fn get_ref < ' a > ( & self ) -> & R { & self . inner }
79
+
80
+ /// Gets a mutable reference to the underlying reader.
78
81
///
79
- /// This type does not expose the ability to get a mutable reference to the
80
- /// underlying reader because that could possibly corrupt the buffer.
81
- pub fn get_ref < ' a > ( & ' a self ) -> & ' a R { & self . inner }
82
+ /// ## Warning
83
+ ///
84
+ /// It is inadvisable to directly read from the underlying reader.
85
+ pub fn get_mut ( & mut self ) -> & mut R { & mut self . inner }
82
86
83
87
/// Unwraps this `BufferedReader`, returning the underlying reader.
84
88
///
@@ -176,10 +180,14 @@ impl<W: Writer> BufferedWriter<W> {
176
180
}
177
181
178
182
/// Gets a reference to the underlying writer.
183
+ pub fn get_ref ( & self ) -> & W { self . inner . as_ref ( ) . unwrap ( ) }
184
+
185
+ /// Gets a mutable reference to the underlying write.
179
186
///
180
- /// This type does not expose the ability to get a mutable reference to the
181
- /// underlying reader because that could possibly corrupt the buffer.
182
- pub fn get_ref < ' a > ( & ' a self ) -> & ' a W { self . inner . as_ref ( ) . unwrap ( ) }
187
+ /// ## Warning
188
+ ///
189
+ /// It is inadvisable to directly read from the underlying writer.
190
+ pub fn get_mut ( & mut self ) -> & mut W { self . inner . as_mut ( ) . unwrap ( ) }
183
191
184
192
/// Unwraps this `BufferedWriter`, returning the underlying writer.
185
193
///
@@ -341,14 +349,22 @@ impl<S: Stream> BufferedStream<S> {
341
349
}
342
350
343
351
/// Gets a reference to the underlying stream.
344
- ///
345
- /// This type does not expose the ability to get a mutable reference to the
346
- /// underlying reader because that could possibly corrupt the buffer.
347
- pub fn get_ref < ' a > ( & ' a self ) -> & ' a S {
352
+ pub fn get_ref ( & self ) -> & S {
348
353
let InternalBufferedWriter ( ref w) = self . inner . inner ;
349
354
w. get_ref ( )
350
355
}
351
356
357
+ /// Gets a mutable reference to the underlying stream.
358
+ ///
359
+ /// ## Warning
360
+ ///
361
+ /// It is inadvisable to read directly from or write directly to the
362
+ /// underlying stream.
363
+ pub fn get_mut ( & mut self ) -> & mut S {
364
+ let InternalBufferedWriter ( ref mut w) = self . inner . inner ;
365
+ w. get_mut ( )
366
+ }
367
+
352
368
/// Unwraps this `BufferedStream`, returning the underlying stream.
353
369
///
354
370
/// The internal buffer is flushed before returning the stream. Any leftover
0 commit comments