diff options
author | metamuffin <metamuffin@disroot.org> | 2023-09-04 09:41:23 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-09-04 09:41:23 +0200 |
commit | 43d4264d763e21b94124a35b81ae609f47bab8bd (patch) | |
tree | 6631cfeb3b97064aa939ba34e01069c3f79d3710 | |
parent | 186bf476aeab0ff0838d1ae26a9dbcb2e40a8eb5 (diff) | |
download | gnix-43d4264d763e21b94124a35b81ae609f47bab8bd.tar gnix-43d4264d763e21b94124a35b81ae609f47bab8bd.tar.bz2 gnix-43d4264d763e21b94124a35b81ae609f47bab8bd.tar.zst |
use #[from] in error types
-rw-r--r-- | src/error.rs | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/error.rs b/src/error.rs index 5aae6d8..59f4443 100644 --- a/src/error.rs +++ b/src/error.rs @@ -13,22 +13,11 @@ pub enum ServiceError { #[error("not found")] NotFound, #[error("io error: {0}")] - Io(std::io::Error), + Io(#[from] std::io::Error), #[error("bad range")] BadRange, #[error("bad utf8")] - BadUtf8, + BadUtf8(#[from] std::str::Utf8Error), #[error("ohh. i didn't expect that this error can be generated.")] Other, } - -impl From<std::io::Error> for ServiceError { - fn from(e: std::io::Error) -> Self { - Self::Io(e) - } -} -impl From<std::str::Utf8Error> for ServiceError { - fn from(_: std::str::Utf8Error) -> Self { - Self::BadUtf8 - } -} |