Skip to content

Commit 18b094b

Browse files
committed
Add doc example for std::io::repeat.
1 parent a0f572e commit 18b094b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/io/util.rs

+10
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ pub struct Repeat { byte: u8 }
113113
///
114114
/// All reads from this reader will succeed by filling the specified buffer with
115115
/// the given byte.
116+
///
117+
/// # Examples
118+
///
119+
/// ```
120+
/// use std::io::{self, Read};
121+
///
122+
/// let mut buffer = [0; 3];
123+
/// io::repeat(0b101).read_exact(&mut buffer).unwrap();
124+
/// assert_eq!(buffer, [0b101, 0b101, 0b101]);
125+
/// ```
116126
#[stable(feature = "rust1", since = "1.0.0")]
117127
pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } }
118128

0 commit comments

Comments
 (0)