]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #34518 - frewsxcv:io-repeat, r=GuillaumeGomez
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Tue, 28 Jun 2016 14:05:16 +0000 (16:05 +0200)
committerGitHub <noreply@github.com>
Tue, 28 Jun 2016 14:05:16 +0000 (16:05 +0200)
Add doc example for `std::io::repeat`.

None

src/libstd/io/util.rs

index c18315c49479216293759975285efc9d575d777c..7df2db9ee650dad4f0f631d433b1c016b2e98425 100644 (file)
@@ -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 } }