Skip to content

Commit 69d60de

Browse files
authored
Rollup merge of #118623 - haydonryan:master, r=workingjubilee
Improve std::fs::read_to_string example Resolves [#118621](rust-lang/rust#118621) For the original code to succeed it requires address.txt to contain a socketaddress, however it is much easier to follow if this is just any strong - eg address could be a street address or just text. Also changed the variable name from "foo" to something more meaningful as cargo clippy warns you against using foo as a placeholder. ``` $ cat main.rs use std::fs; use std::error::Error; fn main() -> Result<(), Box<dyn Error>> { let addr: String = fs::read_to_string("address.txt")?.parse()?; println!("{}", addr); Ok(()) } $ cat address.txt 123 rusty lane san francisco 94999 $ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.00s Running `/home/haydon/workspace/rust-test-pr/tester/target/debug/tester` 123 rusty lane san francisco 94999 ```
2 parents abc737e + 01146ea commit 69d60de

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)