From 14c9abbfeaf65db8f813f5b18fc3e0bd3e8feeff Mon Sep 17 00:00:00 2001 From: baoyachi Date: Sat, 15 Oct 2022 21:36:03 +0800 Subject: [PATCH] fix #115 --- Cargo.toml | 2 +- src/env.rs | 2 +- src/err.rs | 20 ++++++++++++-------- src/git.rs | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index efe7ef7..60db506 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shadow-rs" -version = "0.16.3" +version = "0.17.0" authors = ["baoyachi "] edition = "2021" description = "A build-time information stored in your rust project" diff --git a/src/env.rs b/src/env.rs index f85b6d9..c4a5e4d 100644 --- a/src/env.rs +++ b/src/env.rs @@ -264,7 +264,7 @@ pub fn new_system_env(std_env: &BTreeMap) -> BTreeMap = Result; @@ -15,14 +17,6 @@ impl ShadowError { } } -impl ToString for ShadowError { - fn to_string(&self) -> String { - match self { - ShadowError::String(e) => e.to_string(), - } - } -} - impl From for ShadowError { fn from(e: FromUtf8Error) -> Self { ShadowError::String(e.to_string()) @@ -58,3 +52,13 @@ impl From for ShadowError { ShadowError::String(e.to_string()) } } + +impl Display for ShadowError { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + ShadowError::String(err) => f.write_str(err), + } + } +} + +impl StdError for ShadowError {} diff --git a/src/git.rs b/src/git.rs index 6651f6c..bd9273c 100644 --- a/src/git.rs +++ b/src/git.rs @@ -256,7 +256,7 @@ pub fn new_git( ); if let Err(e) = git.init(path, std_env) { - println!("{}", e.to_string()); + println!("{}", e); } git.map