diff --git a/Cargo.toml b/Cargo.toml index 49c1ebe..cbb357c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,12 @@ categories = ["os", "filesystem"] keywords = ["which", "which-rs", "unix", "command"] [dependencies] -failure = "0.1.1" libc = "0.2.10" +[dependencies.failure] +version = "0.1.1" +default-features = false +features = ["std"] + [dev-dependencies] tempdir = "0.3.4" diff --git a/src/error.rs b/src/error.rs index c7f3850..e108654 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,15 +9,26 @@ pub struct Error { // To suppress false positives from cargo-clippy #[cfg_attr(feature = "cargo-clippy", allow(empty_line_after_outer_attr))] -#[derive(Copy, Clone, Eq, PartialEq, Debug, Fail)] +#[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum ErrorKind { - #[fail(display = "Bad absolute path")] BadAbsolutePath, - - #[fail(display = "Bad relative path")] BadRelativePath, + BadAbsolutePath, + BadRelativePath, + CannotFindBinaryPath, + CannotGetCurrentDir, +} - #[fail(display = "Cannot find binary path")] CannotFindBinaryPath, +impl Fail for ErrorKind {} - #[fail(display = "Cannot get current directory")] CannotGetCurrentDir, +impl Display for ErrorKind { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let display = match *self { + ErrorKind::BadAbsolutePath => "Bad absolute path", + ErrorKind::BadRelativePath => "Bad relative path", + ErrorKind::CannotFindBinaryPath => "Cannot find binary path", + ErrorKind::CannotGetCurrentDir => "Cannot get current directory", + }; + f.write_str(display) + } } impl Fail for Error { diff --git a/src/lib.rs b/src/lib.rs index e225f46..0e3cd8c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,6 @@ //! //! ``` -#[macro_use] extern crate failure; extern crate libc; #[cfg(test)]