diff options
| author | Corey Farwell <coreyf@rwell.org> | 2016-06-27 21:13:26 -0400 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2016-06-27 22:28:28 -0400 |
| commit | a350ca62cdf2ee7cc11ff2c03bd6bb27e0db7024 (patch) | |
| tree | 474edb72749e7929ca078c4f7414c5dc2aadb6c3 /src/libstd | |
| parent | a0f572e98bacc719aa211b1fe97c61339cf6c93a (diff) | |
| download | rust-a350ca62cdf2ee7cc11ff2c03bd6bb27e0db7024.tar.gz rust-a350ca62cdf2ee7cc11ff2c03bd6bb27e0db7024.zip | |
Minor rewrite of `std::io::empty` doc example.
Remove unnecessary hidden `foo` function. Demonstrate this emptiness of the resulting string. Combine imports.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/util.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 2815c0163d6..c18315c4947 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<String> { /// 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: () } } |
