Skip to content

Commit c8b2c7b

Browse files
committed
Modernize std::error::Error impl, update dependencies
1 parent 529ae39 commit c8b2c7b

File tree

3 files changed

+120
-71
lines changed

3 files changed

+120
-71
lines changed

Cargo.lock

Lines changed: 103 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ description = "A tool for cleaning old git branches."
77
documentation = "https://github.com/mcasper/git-clean"
88
homepage = "https://github.com/mcasper/git-clean"
99
repository = "https://github.com/mcasper/git-clean"
10+
autotests = false
1011

1112
[dependencies]
12-
clap = "2.23"
13+
clap = "2.33.1"
1314

1415
[dev-dependencies]
1516
tempdir = "0.3"

src/error.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,32 @@ pub enum Error {
1414
use self::Error::*;
1515

1616
impl StdError for Error {
17-
fn description(&self) -> &str {
17+
fn source(&self) -> Option<&(dyn StdError + 'static)> {
1818
match *self {
19-
Io(ref io_error) => io_error.description(),
20-
ExitEarly => "",
19+
Io(ref io_error) => Some(io_error),
20+
_ => None,
21+
}
22+
}
23+
}
24+
25+
impl Display for Error {
26+
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
27+
match *self {
28+
Io(ref io_error) => io_error.fmt(f),
29+
ExitEarly => Ok(()),
2130
GitInstallationError => {
22-
"Unable to execute 'git' on your machine, please make sure it's installed and on \
23-
your PATH"
31+
write!(f, "Unable to execute 'git' on your machine, please make sure it's installed and on your PATH")
2432
}
2533
CurrentBranchInvalidError => {
26-
"Please make sure to run git-clean from your base branch (defaults to master)."
34+
write!(f, "Please make sure to run git-clean from your base branch (defaults to master).")
2735
}
2836
InvalidRemoteError => {
29-
"That remote doesn't exist, please make sure to use a valid remote (defaults to \
30-
origin)."
37+
write!(f, "That remote doesn't exist, please make sure to use a valid remote (defaults to origin).")
3138
}
3239
}
3340
}
3441
}
3542

36-
impl Display for Error {
37-
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
38-
self.description().fmt(f)
39-
}
40-
}
41-
4243
impl From<IoError> for Error {
4344
fn from(error: IoError) -> Error {
4445
Io(error)

0 commit comments

Comments
 (0)