about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2015-07-10 13:49:12 -0400
committerSteve Klabnik <steve@steveklabnik.com>2015-07-16 13:38:20 -0400
commit4fb02a391d7e1ef3e94d00f10af18304e5c1b53f (patch)
treee95b306dc454eaa21558254309c113a941af7bbd
parent664449ac6e4b607722af4c3defe56af1a40c0a77 (diff)
downloadrust-4fb02a391d7e1ef3e94d00f10af18304e5c1b53f.tar.gz
rust-4fb02a391d7e1ef3e94d00f10af18304e5c1b53f.zip
More docs for std::io free functions.
-rw-r--r--src/libstd/io/mod.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 7f3713a959b..2551ffb2c05 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -149,22 +149,23 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
 ///
 /// ```
 /// use std::io;
+/// use std::io::prelude::*;
 /// use std::fs::File;
-/// use std::io::Read;
 ///
 /// # fn foo() -> io::Result<()> {
 /// let mut f = try!(File::open("foo.txt"));
-/// let mut buffer = Vec::new();
+/// let mut buffer = [0; 10];
 ///
-/// // read some bytes
-/// f.read(&mut buffer).unwrap();
+/// // read up to 10 bytes
+/// try!(f.read(&mut buffer));
 ///
+/// let mut buffer = vec![0; 10];
 /// // read the whole file
-/// f.read_to_end(&mut buffer).unwrap();
+/// try!(f.read_to_end(&mut buffer));
 ///
 /// // read into a String, so that you don't need to do the conversion.
 /// let mut buffer = String::new();
-/// f.read_to_string(&mut buffer).unwrap();
+/// try!(f.read_to_string(&mut buffer));
 ///
 /// // and more! See the other methods for more details.
 /// # Ok(())
@@ -910,7 +911,7 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
 ///
 /// ```
 /// use std::io;
-/// use std::io::BufRead;
+/// use std::io::prelude::*;
 ///
 /// let stdin = io::stdin();
 /// 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>)
 /// [file]: ../fs/struct.File.html
 ///
 /// ```
-/// use std::io;
+/// use std::io::{self, BufReader};
+/// use std::io::prelude::*;
 /// use std::fs::File;
-/// use std::io::BufRead;
-/// use std::io::BufReader;
 ///
 /// # fn foo() -> io::Result<()> {
 /// let f = try!(File::open("foo.txt"));