about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-30 13:30:41 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-30 13:30:41 +0200
commit2bed205d3be05682b84693edeed4d84d850eb801 (patch)
treedb30c8da80ec66aed82019145aa17299bb6264e4 /src/libstd
parentaeb3af898ae426031376a345f91e04bfc7af32f8 (diff)
downloadrust-2bed205d3be05682b84693edeed4d84d850eb801.tar.gz
rust-2bed205d3be05682b84693edeed4d84d850eb801.zip
Add io::Take doc example
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/mod.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index d5b255ee573..3d1ee5b7ae7 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -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 }
 }