@@ -149,22 +149,23 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
149
149
///
150
150
/// ```
151
151
/// use std::io;
152
+ /// use std::io::prelude::*;
152
153
/// use std::fs::File;
153
- /// use std::io::Read;
154
154
///
155
155
/// # fn foo() -> io::Result<()> {
156
156
/// let mut f = try!(File::open("foo.txt"));
157
- /// let mut buffer = Vec::new() ;
157
+ /// let mut buffer = [0; 10] ;
158
158
///
159
- /// // read some bytes
160
- /// f.read(&mut buffer).unwrap( );
159
+ /// // read up to 10 bytes
160
+ /// try!( f.read(&mut buffer));
161
161
///
162
+ /// let mut buffer = vec![0; 10];
162
163
/// // read the whole file
163
- /// f.read_to_end(&mut buffer).unwrap( );
164
+ /// try!( f.read_to_end(&mut buffer));
164
165
///
165
166
/// // read into a String, so that you don't need to do the conversion.
166
167
/// let mut buffer = String::new();
167
- /// f.read_to_string(&mut buffer).unwrap( );
168
+ /// try!( f.read_to_string(&mut buffer));
168
169
///
169
170
/// // and more! See the other methods for more details.
170
171
/// # Ok(())
@@ -910,7 +911,7 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
910
911
///
911
912
/// ```
912
913
/// use std::io;
913
- /// use std::io::BufRead ;
914
+ /// use std::io::prelude::* ;
914
915
///
915
916
/// let stdin = io::stdin();
916
917
/// for line in stdin.lock().lines() {
@@ -928,10 +929,9 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
928
929
/// [file]: ../fs/struct.File.html
929
930
///
930
931
/// ```
931
- /// use std::io;
932
+ /// use std::io::{self, BufReader};
933
+ /// use std::io::prelude::*;
932
934
/// use std::fs::File;
933
- /// use std::io::BufRead;
934
- /// use std::io::BufReader;
935
935
///
936
936
/// # fn foo() -> io::Result<()> {
937
937
/// let f = try!(File::open("foo.txt"));
0 commit comments