File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,15 @@ pub trait Read {
213213 read_to_end ( self , buf)
214214 }
215215
216+ /// Read all bytes until EOF in this source, returning them as a new `Vec`.
217+ ///
218+ /// See `read_to_end` for other semantics.
219+ fn read_into_vec ( & mut self ) -> Result < Vec < u8 > > {
220+ let mut buf = Vec :: new ( ) ;
221+ let res = self . read_to_end ( & mut buf) ;
222+ res. map ( |_| buf)
223+ }
224+
216225 /// Read all bytes until EOF in this source, placing them into `buf`.
217226 ///
218227 /// # Errors
@@ -233,6 +242,15 @@ pub trait Read {
233242 // know is guaranteed to only read data into the end of the buffer.
234243 append_to_string ( buf, |b| read_to_end ( self , b) )
235244 }
245+
246+ /// Read all bytes until EOF in this source, returning them as a new buffer.
247+ ///
248+ /// See `read_to_string` for other semantics.
249+ fn read_into_string ( & mut self , buf : & mut String ) -> Result < String > {
250+ let mut buf = String :: new ( ) ;
251+ let res = self . read_to_string ( & mut buf) ;
252+ res. map ( |_| buf)
253+ }
236254}
237255
238256/// Extension methods for all instances of `Read`, typically imported through
You can’t perform that action at this time.
0 commit comments