trpl-zh-cn/listings/ch09-error-handling/listing-09-09/src/main.rs
2022-02-06 16:43:51 +08:00

13 lines
255 B
Rust
Executable File

// ANCHOR: here
use std::fs;
use std::io;
fn read_username_from_file() -> Result<String, io::Error> {
fs::read_to_string("hello.txt")
}
// ANCHOR_END: here
fn main() {
let username = read_username_from_file().expect("Unable to get username");
}