Minor rewrite of std::io::empty doc example.
Remove unnecessary hidden `foo` function. Demonstrate this emptiness of the resulting string. Combine imports.
This commit is contained in:
@@ -78,14 +78,11 @@ pub struct Empty { _priv: () }
|
|||||||
/// A slightly sad example of not reading anything into a buffer:
|
/// A slightly sad example of not reading anything into a buffer:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::io;
|
/// use std::io::{self, Read};
|
||||||
/// use std::io::Read;
|
|
||||||
///
|
///
|
||||||
/// # fn foo() -> io::Result<String> {
|
|
||||||
/// let mut buffer = String::new();
|
/// let mut buffer = String::new();
|
||||||
/// try!(io::empty().read_to_string(&mut buffer));
|
/// io::empty().read_to_string(&mut buffer).unwrap();
|
||||||
/// # Ok(buffer)
|
/// assert!(buffer.is_empty());
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn empty() -> Empty { Empty { _priv: () } }
|
pub fn empty() -> Empty { Empty { _priv: () } }
|
||||||
|
|||||||
Reference in New Issue
Block a user