Skip to content

Commit

Permalink
Merge pull request #27 from Bzomak/remove-thiserror
Browse files Browse the repository at this point in the history
Remove thiserror crate
  • Loading branch information
Xaeroxe authored Mar 10, 2021
2 parents e345ef7 + 2d4e72a commit 57c08c8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
23 changes: 16 additions & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
use thiserror;
use std::fmt;

pub type Result<T> = std::result::Result<T, Error>;

#[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"),
}
}
}
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
extern crate either;
extern crate libc;
extern crate thiserror;

mod checker;
mod error;
Expand Down

0 comments on commit 57c08c8

Please sign in to comment.