diff --git a/src/config.rs b/src/config.rs index db9a7d7..a70a0dd 100644 --- a/src/config.rs +++ b/src/config.rs @@ -215,15 +215,15 @@ impl Config { .package .as_ref() .ok_or(ConfigError::Missing("package"))?; - let name = get_str_from_metadata!("name").unwrap_or(pkg.name.as_str()); - let version = get_str_from_metadata!("version").unwrap_or(pkg.version.as_str()); + let name = get_str_from_metadata!("name").unwrap_or_else(||pkg.name.as_str()); + let version = get_str_from_metadata!("version").unwrap_or_else(||pkg.version.as_str()); let license = get_str_from_metadata!("license").unwrap_or( pkg.license .as_ref() .ok_or(ConfigError::Missing("package.license"))? .as_str(), ); - let arch = target_arch.unwrap_or( + let arch = target_arch.unwrap_or_else(|| match ARCH { "x86" => "i586", "arm" => "armhfp", @@ -252,7 +252,7 @@ impl Config { ] .iter() .find(|v| v.exists()) - .ok_or(ConfigError::AssetFileNotFound(file.source.to_string()))? + .ok_or_else(||ConfigError::AssetFileNotFound(file.source.to_string()))? .to_owned(); builder = builder.with_file(file_source, options)?; diff --git a/src/error.rs b/src/error.rs index 5633fd0..3be1670 100644 --- a/src/error.rs +++ b/src/error.rs @@ -3,7 +3,6 @@ use rpm::RPMError; use std::ffi::OsString; use std::io::Error as IoError; use std::path::PathBuf; -use thiserror; #[derive(thiserror::Error, Debug, Clone)] pub enum ConfigError { diff --git a/src/main.rs b/src/main.rs index bebf835..c0366ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -85,7 +85,7 @@ fn parse_arg() -> Result<(Option, Option, Option, AutoR std::process::exit(0); } let target_arch = opt_matches.opt_str("a"); - let target_file = opt_matches.opt_str("o").map(|v| PathBuf::from(v)); + let target_file = opt_matches.opt_str("o").map(PathBuf::from); let package = opt_matches.opt_str("p"); let auto_req_mode = AutoReqMode::try_from( opt_matches