diff options
| author | Corey Farwell <coreyf@rwell.org> | 2016-06-27 21:23:53 -0400 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2016-06-27 21:23:53 -0400 |
| commit | 18b094bdbd6b26cb752bf36f06bed1291a73f0ff (patch) | |
| tree | 7486a27c35771d96556f45d9133ee4ea7210329a /src/libstd/io | |
| parent | a0f572e98bacc719aa211b1fe97c61339cf6c93a (diff) | |
| download | rust-18b094bdbd6b26cb752bf36f06bed1291a73f0ff.tar.gz rust-18b094bdbd6b26cb752bf36f06bed1291a73f0ff.zip | |
Add doc example for `std::io::repeat`.
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/util.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 2815c0163d6..a8683723cad 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -113,6 +113,16 @@ pub struct Repeat { byte: u8 } /// /// All reads from this reader will succeed by filling the specified buffer with /// the given byte. +/// +/// # Examples +/// +/// ``` +/// use std::io::{self, Read}; +/// +/// let mut buffer = [0; 3]; +/// io::repeat(0b101).read_exact(&mut buffer).unwrap(); +/// assert_eq!(buffer, [0b101, 0b101, 0b101]); +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } |
