From 325e09e952264ad5b1bccbeb5774446f3c601957 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 28 Jun 2016 08:22:34 -0400 Subject: [PATCH] Add doc example for `std::io::sink`. --- src/libstd/io/util.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 2815c0163d68a..e5d6cb2b34e60 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -139,6 +139,16 @@ pub struct Sink { _priv: () } /// /// All calls to `write` on the returned instance will return `Ok(buf.len())` /// and the contents of the buffer will not be inspected. +/// +/// # Examples +/// +/// ```rust +/// use std::io::{self, Write}; +/// +/// let mut buffer = vec![1, 2, 3, 5, 8]; +/// let num_bytes = io::sink().write(&mut buffer).unwrap(); +/// assert_eq!(num_bytes, 5); +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn sink() -> Sink { Sink { _priv: () } }