Skip to content

Commit 2bed205

Browse files
Add io::Take doc example
1 parent aeb3af8 commit 2bed205

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/libstd/io/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,24 @@ impl<T> Take<T> {
14821482
///
14831483
/// This instance may reach EOF after reading fewer bytes than indicated by
14841484
/// this method if the underlying `Read` instance reaches EOF.
1485+
///
1486+
/// # Examples
1487+
///
1488+
/// ```
1489+
/// use std::io;
1490+
/// use std::io::prelude::*;
1491+
/// use std::fs::File;
1492+
///
1493+
/// # fn foo() -> io::Result<()> {
1494+
/// let f = try!(File::open("foo.txt"));
1495+
///
1496+
/// // read at most five bytes
1497+
/// let handle = f.take(5);
1498+
///
1499+
/// println!("limit: {}", handle.limit());
1500+
/// # Ok(())
1501+
/// # }
1502+
/// ```
14851503
#[stable(feature = "rust1", since = "1.0.0")]
14861504
pub fn limit(&self) -> u64 { self.limit }
14871505
}

0 commit comments

Comments
 (0)