From 585908a606b5894a91e5d0433c39482e09164ba9 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 29 Jun 2024 17:04:15 +0900 Subject: [PATCH] templater: use .map_or() to silence clippy without sacrificing readability --- cli/src/commit_templater.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cli/src/commit_templater.rs b/cli/src/commit_templater.rs index 58d0523514..daf7b2fd87 100644 --- a/cli/src/commit_templater.rs +++ b/cli/src/commit_templater.rs @@ -1027,15 +1027,8 @@ impl RefNamesIndex { } } - #[allow(unknown_lints)] // XXX FIXME (aseipp): nightly bogons; re-test this occasionally - #[allow(clippy::manual_unwrap_or_default)] - #[allow(clippy::manual_unwrap_or)] // https://github.com/rust-lang/rust-clippy/issues/13018 pub fn get(&self, id: &CommitId) -> &[Rc] { - if let Some(names) = self.index.get(id) { - names - } else { - &[] - } + self.index.get(id).map_or(&[], |names: &Vec<_>| names) } }