File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,15 @@ pub trait Read {
213
213
read_to_end ( self , buf)
214
214
}
215
215
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
+
216
225
/// Read all bytes until EOF in this source, placing them into `buf`.
217
226
///
218
227
/// # Errors
@@ -233,6 +242,15 @@ pub trait Read {
233
242
// know is guaranteed to only read data into the end of the buffer.
234
243
append_to_string ( buf, |b| read_to_end ( self , b) )
235
244
}
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
+ }
236
254
}
237
255
238
256
/// Extension methods for all instances of `Read`, typically imported through
You can’t perform that action at this time.
0 commit comments