Skip to content

Commit 325e09e

Browse files
committed
Add doc example for std::io::sink.
1 parent a0f572e commit 325e09e

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
@@ -139,6 +139,16 @@ pub struct Sink { _priv: () }
139139
///
140140
/// All calls to `write` on the returned instance will return `Ok(buf.len())`
141141
/// and the contents of the buffer will not be inspected.
142+
///
143+
/// # Examples
144+
///
145+
/// ```rust
146+
/// use std::io::{self, Write};
147+
///
148+
/// let mut buffer = vec![1, 2, 3, 5, 8];
149+
/// let num_bytes = io::sink().write(&mut buffer).unwrap();
150+
/// assert_eq!(num_bytes, 5);
151+
/// ```
142152
#[stable(feature = "rust1", since = "1.0.0")]
143153
pub fn sink() -> Sink { Sink { _priv: () } }
144154

0 commit comments

Comments
 (0)