Skip to content

Commit a350ca6

Browse files
committed
Minor rewrite of std::io::empty doc example.
Remove unnecessary hidden `foo` function. Demonstrate this emptiness of the resulting string. Combine imports.
1 parent a0f572e commit a350ca6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/libstd/io/util.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,11 @@ pub struct Empty { _priv: () }
7878
/// A slightly sad example of not reading anything into a buffer:
7979
///
8080
/// ```
81-
/// use std::io;
82-
/// use std::io::Read;
81+
/// use std::io::{self, Read};
8382
///
84-
/// # fn foo() -> io::Result<String> {
8583
/// let mut buffer = String::new();
86-
/// try!(io::empty().read_to_string(&mut buffer));
87-
/// # Ok(buffer)
88-
/// # }
84+
/// io::empty().read_to_string(&mut buffer).unwrap();
85+
/// assert!(buffer.is_empty());
8986
/// ```
9087
#[stable(feature = "rust1", since = "1.0.0")]
9188
pub fn empty() -> Empty { Empty { _priv: () } }

0 commit comments

Comments
 (0)