Skip to content

Commit

Permalink
Fix thiserror slide (google#2380)
Browse files Browse the repository at this point in the history
Fixes google#2379. This has `compile_fail` because `thiserror` isn't available
from within `mdbook test`.
  • Loading branch information
djmitche authored Sep 27, 2024
1 parent 2713ea3 commit 9d2ea42
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/error-handling/thiserror.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ assist in implementing `From<T>`, `Display`, and the `Error` trait.

```rust,editable,compile_fail
use std::fs;
use std::io::Read;
use std::io::{self, Read};
use thiserror::Error;
#[derive(Error)]
#[derive(Debug, Error)]
enum ReadUsernameError {
#[error("I/O error: {0}")]
IoError(#[from] io::Error),
Expand All @@ -23,7 +23,7 @@ enum ReadUsernameError {
fn read_username(path: &str) -> Result<String, ReadUsernameError> {
let mut username = String::with_capacity(100);
File::open(path)?.read_to_string(&mut username)?;
fs::File::open(path)?.read_to_string(&mut username)?;
if username.is_empty() {
return Err(ReadUsernameError::EmptyUsername(String::from(path)));
}
Expand Down

0 comments on commit 9d2ea42

Please sign in to comment.