]> git.lizzy.rs Git - rust.git/commitdiff
Add doc example for `std::io::repeat`.
authorCorey Farwell <coreyf@rwell.org>
Tue, 28 Jun 2016 01:23:53 +0000 (21:23 -0400)
committerCorey Farwell <coreyf@rwell.org>
Tue, 28 Jun 2016 01:23:53 +0000 (21:23 -0400)
src/libstd/io/util.rs

index 2815c0163d68a86e448dc50f459b0c00663c4e21..a8683723cad667a4137cccb7119bed401e2e393d 100644 (file)
@@ -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 } }