diff --git a/Cargo.toml b/Cargo.toml index 1a3695c..97b80ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ time = { version = "0.3.11", features = ["formatting", "local-offset", "parsing" #! Optional Dependencies: ## Use `libgit2` as a backend for git operations -git2 = { version = "0.18.0", default-features = false, optional = true } +git2 = { version = "0.18.2", default-features = false, optional = true } ## Better support for querying the local system time tzdb = { version = "0.6.0", optional = true, default-features = false, features = ["local"] } diff --git a/src/build.rs b/src/build.rs index 12365d8..fed93a1 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,12 +1,8 @@ -use std::collections::BTreeMap; +use std::fmt::{Display, Formatter}; /// `shadow-rs` build constant identifiers. pub type ShadowConst = &'static str; -pub trait ShadowGen { - fn gen_const(&self) -> BTreeMap; -} - /// Serialized values for build constants. #[derive(Debug, Clone)] pub struct ConstVal { @@ -47,12 +43,12 @@ pub enum ConstType { Bool, } -impl ToString for ConstType { - fn to_string(&self) -> String { +impl Display for ConstType { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { - ConstType::OptStr => "Option<&str>".to_string(), - ConstType::Str => "&str".to_string(), - ConstType::Bool => "bool".to_string(), + ConstType::OptStr => write!(f, "Option<&str>"), + ConstType::Str => write!(f, "&str"), + ConstType::Bool => write!(f, "bool"), } } } diff --git a/src/ci.rs b/src/ci.rs index 518b864..c2c7b4c 100644 --- a/src/ci.rs +++ b/src/ci.rs @@ -1,3 +1,5 @@ +use std::fmt::{Display, Formatter}; + /// [`CiType`] holds the types of CI environment that `shadow-rs` can detect. #[derive(Debug)] pub enum CiType { @@ -13,12 +15,12 @@ impl Default for CiType { } } -impl ToString for CiType { - fn to_string(&self) -> String { +impl Display for CiType { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { - CiType::Github => "github".into(), - CiType::Gitlab => "gitlab".into(), - _ => "none".into(), + CiType::Github => write!(f, "github"), + CiType::Gitlab => write!(f, "gitlab"), + _ => write!(f, "none"), } } } diff --git a/src/err.rs b/src/err.rs index f54ad2f..6cc0984 100644 --- a/src/err.rs +++ b/src/err.rs @@ -1,4 +1,3 @@ -use std::convert::From; use std::error::Error; use std::error::Error as StdError; use std::fmt::{Display, Formatter}; diff --git a/src/git.rs b/src/git.rs index a024c30..deefb61 100644 --- a/src/git.rs +++ b/src/git.rs @@ -508,7 +508,6 @@ fn filter_git_dirty_stage(dirty_files: Vec, staged_files: Vec) - mod tests { use super::*; use crate::get_std_env; - use std::path::Path; #[test] fn test_git() { @@ -535,7 +534,7 @@ mod tests { #[test] fn test_current_branch() { - if get_std_env().get("GITHUB_REF").is_some() { + if get_std_env().contains_key("GITHUB_REF") { return; } #[cfg(feature = "git2")] diff --git a/src/lib.rs b/src/lib.rs index 0e34418..c5360d6 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -446,7 +446,7 @@ impl Shadow { #[allow(clippy::all)]\n\ pub const {} :{} = r#\"{}\"#;", shadow_const.to_ascii_uppercase(), - ConstType::Str.to_string(), + ConstType::Str, "" ), ConstType::Str => format!( @@ -454,14 +454,14 @@ impl Shadow { #[allow(clippy::all)]\n\ pub const {} :{} = r#\"{}\"#;", shadow_const.to_ascii_uppercase(), - ConstType::Str.to_string(), + ConstType::Str, val.v ), ConstType::Bool => format!( "#[allow(dead_code)]\n\ pub const {} :{} = {};", shadow_const.to_ascii_uppercase(), - ConstType::Bool.to_string(), + ConstType::Bool, val.v.parse::().unwrap() ), };