Skip to content

Commit

Permalink
Minor rewrite of std::io::empty doc example.
Browse files Browse the repository at this point in the history
Remove unnecessary hidden `foo` function.
Demonstrate this emptiness of the resulting string.
Combine imports.
  • Loading branch information
frewsxcv committed Jun 28, 2016
1 parent a0f572e commit a350ca6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/libstd/io/util.rs
Expand Up @@ -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: () } }
Expand Down

0 comments on commit a350ca6

Please sign in to comment.