Skip to content

Commit dd56a6a

Browse files
Rollup merge of #34524 - frewsxcv:std-io-sink, r=GuillaumeGomez
Add doc example for `std::io::sink`. None
2 parents dcc8fa5 + 325e09e commit dd56a6a

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
@@ -146,6 +146,16 @@ pub struct Sink { _priv: () }
146146
///
147147
/// All calls to `write` on the returned instance will return `Ok(buf.len())`
148148
/// and the contents of the buffer will not be inspected.
149+
///
150+
/// # Examples
151+
///
152+
/// ```rust
153+
/// use std::io::{self, Write};
154+
///
155+
/// let mut buffer = vec![1, 2, 3, 5, 8];
156+
/// let num_bytes = io::sink().write(&mut buffer).unwrap();
157+
/// assert_eq!(num_bytes, 5);
158+
/// ```
149159
#[stable(feature = "rust1", since = "1.0.0")]
150160
pub fn sink() -> Sink { Sink { _priv: () } }
151161

0 commit comments

Comments
 (0)