Skip to content

Commit 4fb02a3

Browse files
committed
More docs for std::io free functions.
1 parent 664449a commit 4fb02a3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/libstd/io/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,23 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
149149
///
150150
/// ```
151151
/// use std::io;
152+
/// use std::io::prelude::*;
152153
/// use std::fs::File;
153-
/// use std::io::Read;
154154
///
155155
/// # fn foo() -> io::Result<()> {
156156
/// let mut f = try!(File::open("foo.txt"));
157-
/// let mut buffer = Vec::new();
157+
/// let mut buffer = [0; 10];
158158
///
159-
/// // read some bytes
160-
/// f.read(&mut buffer).unwrap();
159+
/// // read up to 10 bytes
160+
/// try!(f.read(&mut buffer));
161161
///
162+
/// let mut buffer = vec![0; 10];
162163
/// // read the whole file
163-
/// f.read_to_end(&mut buffer).unwrap();
164+
/// try!(f.read_to_end(&mut buffer));
164165
///
165166
/// // read into a String, so that you don't need to do the conversion.
166167
/// let mut buffer = String::new();
167-
/// f.read_to_string(&mut buffer).unwrap();
168+
/// try!(f.read_to_string(&mut buffer));
168169
///
169170
/// // and more! See the other methods for more details.
170171
/// # Ok(())
@@ -910,7 +911,7 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
910911
///
911912
/// ```
912913
/// use std::io;
913-
/// use std::io::BufRead;
914+
/// use std::io::prelude::*;
914915
///
915916
/// let stdin = io::stdin();
916917
/// 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>)
928929
/// [file]: ../fs/struct.File.html
929930
///
930931
/// ```
931-
/// use std::io;
932+
/// use std::io::{self, BufReader};
933+
/// use std::io::prelude::*;
932934
/// use std::fs::File;
933-
/// use std::io::BufRead;
934-
/// use std::io::BufReader;
935935
///
936936
/// # fn foo() -> io::Result<()> {
937937
/// let f = try!(File::open("foo.txt"));

0 commit comments

Comments
 (0)