Add io::Take doc example
This commit is contained in:
parent
aeb3af898a
commit
2bed205d3b
1 changed files with 18 additions and 0 deletions
|
|
@ -1482,6 +1482,24 @@ impl<T> Take<T> {
|
|||
///
|
||||
/// This instance may reach EOF after reading fewer bytes than indicated by
|
||||
/// this method if the underlying `Read` instance reaches EOF.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::io;
|
||||
/// use std::io::prelude::*;
|
||||
/// use std::fs::File;
|
||||
///
|
||||
/// # fn foo() -> io::Result<()> {
|
||||
/// let f = try!(File::open("foo.txt"));
|
||||
///
|
||||
/// // read at most five bytes
|
||||
/// let handle = f.take(5);
|
||||
///
|
||||
/// println!("limit: {}", handle.limit());
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn limit(&self) -> u64 { self.limit }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue