From 4fb02a391d7e1ef3e94d00f10af18304e5c1b53f Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 10 Jul 2015 13:49:12 -0400 Subject: [PATCH] More docs for std::io free functions. --- src/libstd/io/mod.rs | 20 ++++++++++---------- 1 file 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: &mut R, buf: &mut Vec) -> Result /// /// ``` /// 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: &mut R, delim: u8, buf: &mut Vec) /// /// ``` /// 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: &mut R, delim: u8, buf: &mut Vec) /// [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"));