From cd018e90a15e9960c0998bbfdd284d65029691f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Fri, 31 Dec 2021 21:27:52 +0300 Subject: [PATCH] refactor(clippy): apply clippy suggestions --- git-cliff-core/src/commit.rs | 5 +---- git-cliff-core/src/embed.rs | 2 +- git-cliff-core/src/repo.rs | 3 +-- git-cliff/src/lib.rs | 3 +-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/git-cliff-core/src/commit.rs b/git-cliff-core/src/commit.rs index d61a7c70..8b9c6492 100644 --- a/git-cliff-core/src/commit.rs +++ b/git-cliff-core/src/commit.rs @@ -197,10 +197,7 @@ impl Serialize for Commit<'_> { commit.serialize_field("breaking", &conv.breaking())?; commit.serialize_field( "scope", - &conv - .scope() - .map(|v| v.as_str()) - .or_else(|| self.scope.as_deref()), + &conv.scope().map(|v| v.as_str()).or(self.scope.as_deref()), )?; } None => { diff --git a/git-cliff-core/src/embed.rs b/git-cliff-core/src/embed.rs index d07b24ef..84c86b94 100644 --- a/git-cliff-core/src/embed.rs +++ b/git-cliff-core/src/embed.rs @@ -21,7 +21,7 @@ impl EmbeddedConfig { /// Extracts the embedded content. pub fn get_config() -> Result { match Self::get(crate::DEFAULT_CONFIG) { - Some(v) => Ok(str::from_utf8(&v.data.into_owned())?.to_string()), + Some(v) => Ok(str::from_utf8(&v.data)?.to_string()), None => Err(Error::EmbeddedError(String::from( "Embedded config not found", ))), diff --git a/git-cliff-core/src/repo.rs b/git-cliff-core/src/repo.rs index 3e68d06e..46b41dbb 100644 --- a/git-cliff-core/src/repo.rs +++ b/git-cliff-core/src/repo.rs @@ -119,8 +119,7 @@ impl Repository { if let Some(commit) = tag .target() .ok() - .map(|target| target.into_commit().ok()) - .flatten() + .and_then(|target| target.into_commit().ok()) { tags.push((commit, name)); } diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index 9fa63d4b..7b6040bc 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -56,8 +56,7 @@ pub fn run(mut args: Opt) -> Result<()> { }?; if let Some(config_path) = dirs_next::config_dir() .map(|dir| dir.join(env!("CARGO_PKG_NAME")).join(DEFAULT_CONFIG)) - .map(|path| path.to_str().map(String::from)) - .flatten() + .and_then(|path| path.to_str().map(String::from)) { if fs::metadata(&config_path).is_ok() { path = config_path;