Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use failure without its derive feature #9

Merged
merged 1 commit into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
23 changes: 17 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//!
//! ```

#[macro_use]
extern crate failure;
extern crate libc;
#[cfg(test)]
Expand Down