diff options
Diffstat (limited to '')
-rw-r--r-- | src/doc/book/listings/ch09-error-handling/listing-09-09/src/main.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch09-error-handling/listing-09-09/src/main.rs b/src/doc/book/listings/ch09-error-handling/listing-09-09/src/main.rs new file mode 100644 index 000000000..4597dc2ee --- /dev/null +++ b/src/doc/book/listings/ch09-error-handling/listing-09-09/src/main.rs @@ -0,0 +1,12 @@ +// 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"); +} |