Skip to content

Commit

Permalink
wire up another serde default to remove thunking
Browse files Browse the repository at this point in the history
Don't go through the as_ref/clone cycle and let serde do the lift.
  • Loading branch information
cardoe committed Dec 3, 2019
1 parent fd06d12 commit 1b38d4a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/config/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ fn default_arch() -> Vec<String> {
vec!["x86_64".to_string()]
}

fn empty_string() -> String {
"".to_string()
}

/// data in `[package.metadata.arch]` section
#[derive(Clone, Debug, Default, Deserialize)]
pub struct CargoArch {
Expand All @@ -35,9 +39,11 @@ pub struct CargoArch {
/// This field specifies the license(s) that apply to the package.
pub license: Option<Vec<String>>,
/// Specifies a special install script that is to be included in the package.
pub install: Option<String>,
#[serde(default = "empty_string")]
pub install: String,
/// Specifies a changelog file that is to be included in the package.
pub changelog: Option<String>,
#[serde(default = "empty_string")]
pub changelog: String,
/// An array of source files required to build the package.
#[serde(default)]
pub source: Vec<String>,
Expand Down Expand Up @@ -282,9 +288,6 @@ impl ToPackageConfig<ArchConfig> for Cargo {
.collect::<Vec<String>>()
).clone();

let install = arch_config.install.as_ref().unwrap_or(&String::new()).clone();
let changelog = arch_config.changelog.as_ref().unwrap_or(&String::new()).clone();

ArchConfig {
maintainers: maintainers,
pkgname: pkgname,
Expand All @@ -294,8 +297,8 @@ impl ToPackageConfig<ArchConfig> for Cargo {
pkgdesc: pkgdesc,
url: url,
license: license,
install: install,
changelog: changelog,
install: arch_config.install.to_string(),
changelog: arch_config.changelog.to_string(),
source: arch_config.source.to_vec(),
validpgpkeys: arch_config.validpgpkeys.to_vec(),
noextract: arch_config.noextract.to_vec(),
Expand Down

0 comments on commit 1b38d4a

Please sign in to comment.