From 0ac245ee614098ff188bc121a33d9cd049603802 Mon Sep 17 00:00:00 2001 From: Alexandre Senges Date: Mon, 14 Aug 2023 16:55:06 +0200 Subject: [PATCH] Invert std::error and thiserror::Error --- src/error-handling/dynamic-errors.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/error-handling/dynamic-errors.md b/src/error-handling/dynamic-errors.md index f3a05b04..14074131 100644 --- a/src/error-handling/dynamic-errors.md +++ b/src/error-handling/dynamic-errors.md @@ -6,13 +6,13 @@ all the different possibilities. `std::error::Error` makes this easy. ```rust,editable,compile_fail use std::fs; use std::io::Read; -use std::error::Error; +use thiserror::Error; -#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)] +#[derive(Clone, Debug, Eq, Error, PartialEq)] #[error("Found no username in {0}")] struct EmptyUsernameError(String); -fn read_username(path: &str) -> Result> { +fn read_username(path: &str) -> Result> { let mut username = String::new(); fs::File::open(path)?.read_to_string(&mut username)?; if username.is_empty() {