More docs for std::io free functions.
This commit is contained in:
parent
664449ac6e
commit
4fb02a391d
1 changed files with 10 additions and 10 deletions
|
@ -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;
|
||||||
|
/// use std::io::prelude::*;
|
||||||
/// use std::fs::File;
|
/// use std::fs::File;
|
||||||
/// use std::io::Read;
|
|
||||||
///
|
///
|
||||||
/// # fn foo() -> io::Result<()> {
|
/// # fn foo() -> io::Result<()> {
|
||||||
/// let mut f = try!(File::open("foo.txt"));
|
/// let mut f = try!(File::open("foo.txt"));
|
||||||
/// let mut buffer = Vec::new();
|
/// let mut buffer = [0; 10];
|
||||||
///
|
///
|
||||||
/// // read some bytes
|
/// // read up to 10 bytes
|
||||||
/// f.read(&mut buffer).unwrap();
|
/// try!(f.read(&mut buffer));
|
||||||
///
|
///
|
||||||
|
/// let mut buffer = vec![0; 10];
|
||||||
/// // read the whole file
|
/// // 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.
|
/// // read into a String, so that you don't need to do the conversion.
|
||||||
/// let mut buffer = String::new();
|
/// 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.
|
/// // and more! See the other methods for more details.
|
||||||
/// # Ok(())
|
/// # 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;
|
||||||
/// use std::io::BufRead;
|
/// use std::io::prelude::*;
|
||||||
///
|
///
|
||||||
/// let stdin = io::stdin();
|
/// let stdin = io::stdin();
|
||||||
/// for line in stdin.lock().lines() {
|
/// 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
|
/// [file]: ../fs/struct.File.html
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::io;
|
/// use std::io::{self, BufReader};
|
||||||
|
/// use std::io::prelude::*;
|
||||||
/// use std::fs::File;
|
/// use std::fs::File;
|
||||||
/// use std::io::BufRead;
|
|
||||||
/// use std::io::BufReader;
|
|
||||||
///
|
///
|
||||||
/// # fn foo() -> io::Result<()> {
|
/// # fn foo() -> io::Result<()> {
|
||||||
/// let f = try!(File::open("foo.txt"));
|
/// let f = try!(File::open("foo.txt"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue