Skip to content

Commit dcc8fa5

Browse files
Rollup merge of #34518 - frewsxcv:io-repeat, r=GuillaumeGomez
Add doc example for `std::io::repeat`. None
2 parents f47fcc7 + 18b094b commit dcc8fa5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/io/util.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ pub struct Repeat { byte: u8 }
110110
///
111111
/// All reads from this reader will succeed by filling the specified buffer with
112112
/// the given byte.
113+
///
114+
/// # Examples
115+
///
116+
/// ```
117+
/// use std::io::{self, Read};
118+
///
119+
/// let mut buffer = [0; 3];
120+
/// io::repeat(0b101).read_exact(&mut buffer).unwrap();
121+
/// assert_eq!(buffer, [0b101, 0b101, 0b101]);
122+
/// ```
113123
#[stable(feature = "rust1", since = "1.0.0")]
114124
pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } }
115125

0 commit comments

Comments
 (0)