about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/errors.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-08 08:19:16 +0100
committerGitHub <noreply@github.com>2024-03-08 08:19:16 +0100
commit876847bed88666bf7bb25de1a0b4fba170420661 (patch)
tree2ccb7cd8de22491a1b643b313a1d0ea96b41638a /compiler/rustc_builtin_macros/src/errors.rs
parent9fb91aa2e70bfcc1c0adaad79711f0321ea81ece (diff)
parentb5e1ca39180e9997efef14d3b7d06a3ddff72b59 (diff)
downloadrust-876847bed88666bf7bb25de1a0b4fba170420661.tar.gz
rust-876847bed88666bf7bb25de1a0b4fba170420661.zip
Rollup merge of #118623 - haydonryan:master, r=workingjubilee
Improve std::fs::read_to_string example

Resolves  [#118621](https://github.com/rust-lang/rust/issues/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

```
Diffstat (limited to 'compiler/rustc_builtin_macros/src/errors.rs')
0 files changed, 0 insertions, 0 deletions