From a350ca62cdf2ee7cc11ff2c03bd6bb27e0db7024 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 27 Jun 2016 21:13:26 -0400 Subject: [PATCH] Minor rewrite of `std::io::empty` doc example. Remove unnecessary hidden `foo` function. Demonstrate this emptiness of the resulting string. Combine imports. --- src/libstd/io/util.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 2815c0163d68a..c18315c494792 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -78,14 +78,11 @@ pub struct Empty { _priv: () } /// A slightly sad example of not reading anything into a buffer: /// /// ``` -/// use std::io; -/// use std::io::Read; +/// use std::io::{self, Read}; /// -/// # fn foo() -> io::Result { /// let mut buffer = String::new(); -/// try!(io::empty().read_to_string(&mut buffer)); -/// # Ok(buffer) -/// # } +/// io::empty().read_to_string(&mut buffer).unwrap(); +/// assert!(buffer.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn empty() -> Empty { Empty { _priv: () } }