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:
parent
a0f572e98b
commit
a350ca62cd
@ -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: () } }
|
||||
|
Loading…
Reference in New Issue
Block a user