diff --git a/Cargo.toml b/Cargo.toml index 5784145..c1c21ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ keywords = ["which", "which-rs", "unix", "command"] [dependencies] either = "1.6" libc = "0.2.65" -thiserror = "1.0" [dev-dependencies] tempdir = "0.3.7" diff --git a/src/error.rs b/src/error.rs index 708c884..6d800a6 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,17 +1,26 @@ -use thiserror; +use std::fmt; pub type Result = std::result::Result; -#[derive(thiserror::Error, Copy, Clone, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum Error { - #[error("bad absolute path")] BadAbsolutePath, - #[error("bad relative path")] BadRelativePath, - #[error("cannot find binary path")] CannotFindBinaryPath, - #[error("cannot get current directory")] CannotGetCurrentDir, - #[error("cannot canonicalize path")] CannotCanonicalize, } + +impl std::error::Error for Error {} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Error::BadAbsolutePath => write!(f, "bad absolute path"), + Error::BadRelativePath => write!(f, "bad relative path"), + Error::CannotFindBinaryPath => write!(f, "cannot find binary path"), + Error::CannotGetCurrentDir => write!(f, "cannot get current directory"), + Error::CannotCanonicalize => write!(f, "cannot canonicalize path"), + } + } +} diff --git a/src/lib.rs b/src/lib.rs index 8d6e145..9232b3e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,6 @@ extern crate either; extern crate libc; -extern crate thiserror; mod checker; mod error;