From 3792f4a019481f9bb31049f04b3ae9c101ac1ee6 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 58d052351..daf7b2fd8 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) } }