about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-06-28 16:05:16 +0200
committerGitHub <noreply@github.com>2016-06-28 16:05:16 +0200
commitdcc8fa52705a2267012cdba7c90662d472ce8d2c (patch)
tree9618b09b29888366142f0a8147c4a5099c6c3433 /src/libstd
parentf47fcc738b49d9dcd3527a4031c101b249c93a03 (diff)
parent18b094bdbd6b26cb752bf36f06bed1291a73f0ff (diff)
downloadrust-dcc8fa52705a2267012cdba7c90662d472ce8d2c.tar.gz
rust-dcc8fa52705a2267012cdba7c90662d472ce8d2c.zip
Rollup merge of #34518 - frewsxcv:io-repeat, r=GuillaumeGomez
Add doc example for `std::io::repeat`.

None
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/util.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs
index c18315c4947..7df2db9ee65 100644
--- a/src/libstd/io/util.rs
+++ b/src/libstd/io/util.rs
@@ -110,6 +110,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 } }