1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-24 16:42:36 +02:00

Error handling: clarify printing of Result

Two examples may print either `Ok(username)` or `Err(error)`.
This commit clarifies this fact.
This commit is contained in:
Ilya Grigoriev 2023-01-06 12:35:05 -08:00 committed by GitHub
parent e074b8c87f
commit 68eed5b4f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -46,6 +46,6 @@ fn read_username(path: &str) -> Result<String, ReadUsernameError> {
fn main() {
//fs::write("config.dat", "").unwrap();
let username = read_username("config.dat");
println!("username: {username:?}");
println!("username or error: {username:?}");
}
```

View File

@ -41,6 +41,6 @@ fn read_username(path: &str) -> Result<String, io::Error> {
fn main() {
//fs::write("config.dat", "alice").unwrap();
let username = read_username("config.dat");
println!("username: {username:?}");
println!("username or error: {username:?}");
}
```