Skip to content

Commit

Permalink
Add io::Take doc example
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 30, 2016
1 parent aeb3af8 commit 2bed205
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down

0 comments on commit 2bed205

Please sign in to comment.