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:
parent
e074b8c87f
commit
68eed5b4f2
@ -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:?}");
|
||||
}
|
||||
```
|
||||
|
@ -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:?}");
|
||||
}
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user