Skip to content

Commit

Permalink
Rollup merge of rust-lang#34518 - frewsxcv:io-repeat, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Add doc example for `std::io::repeat`.

None
  • Loading branch information
GuillaumeGomez authored Jun 28, 2016
2 parents f47fcc7 + 18b094b commit dcc8fa5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libstd/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }

Expand Down

0 comments on commit dcc8fa5

Please sign in to comment.