Skip to content

Commit

Permalink
fix #115
Browse files Browse the repository at this point in the history
  • Loading branch information
baoyachi committed Oct 15, 2022
1 parent 1ce70bb commit 14c9abb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "shadow-rs"
version = "0.16.3"
version = "0.17.0"
authors = ["baoyachi <liaoymxsdl@gmail.com>"]
edition = "2021"
description = "A build-time information stored in your rust project"
Expand Down
2 changes: 1 addition & 1 deletion src/env.rs
Expand Up @@ -264,7 +264,7 @@ pub fn new_system_env(std_env: &BTreeMap<String, String>) -> BTreeMap<ShadowCons
);

if let Err(e) = env.init(std_env) {
println!("{}", e.to_string());
println!("{}", e);
}
env.map
}
Expand Down
20 changes: 12 additions & 8 deletions src/err.rs
@@ -1,5 +1,7 @@
use std::convert::From;
use std::error::Error;
use std::error::Error as StdError;
use std::fmt::{Display, Formatter};
use std::string::FromUtf8Error;

pub type SdResult<T> = Result<T, ShadowError>;
Expand All @@ -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<std::string::FromUtf8Error> for ShadowError {
fn from(e: FromUtf8Error) -> Self {
ShadowError::String(e.to_string())
Expand Down Expand Up @@ -58,3 +52,13 @@ impl From<std::num::ParseIntError> 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 {}
2 changes: 1 addition & 1 deletion src/git.rs
Expand Up @@ -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
Expand Down

0 comments on commit 14c9abb

Please sign in to comment.