Skip to content

Commit

Permalink
Rollup merge of rust-lang#84067 - rust-lang:steveklabnik-patch-1, r=j…
Browse files Browse the repository at this point in the history
…oshtriplett

clean up example on read_to_string

This is the same thing, but simpler.

This came out of a comment from a user: https://news.ycombinator.com/item?id=25318117 but rather than hide the signature of main, I think a `use` plus not including the `'static` makes more sense.
  • Loading branch information
Dylan-DPC authored Apr 11, 2021
2 parents 58f32da + c2f4a5b commit 9c34cbf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
/// ```no_run
/// use std::fs;
/// use std::net::SocketAddr;
/// use std::error::Error;
///
/// fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
/// fn main() -> Result<(), Box<dyn Error>> {
/// let foo: SocketAddr = fs::read_to_string("address.txt")?.parse()?;
/// Ok(())
/// }
Expand Down

0 comments on commit 9c34cbf

Please sign in to comment.