From a1c746cdb98a3d492bd81c2d80def81d45463091 Mon Sep 17 00:00:00 2001 From: Matthew Cheely Date: Tue, 4 Oct 2022 19:18:22 -0400 Subject: [PATCH] Simplify labelled command pattern match Co-authored-by: Michael Davis --- helix-term/src/keymap.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 98521eb3d..cdad51a32 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -217,19 +217,14 @@ impl<'de> serde::de::Visitor<'de> for KeyTrieVisitor { match command { None => Ok(KeyTrie::Node(KeyTrieNode::new(label, mapping, order))), - Some(cmd) => { - let status = (cmd, label.is_empty()); - if let (MappableCommand::Typable { name, args, .. }, false) = status { - Ok(MappableCommand::Typable { - name, - args, - doc: label.to_string(), - }) - .map(KeyTrie::Leaf) - } else { - Ok(KeyTrie::Leaf(status.0)) - } + Some(MappableCommand::Typable { name, args, .. }) if !label.is_empty() => { + Ok(KeyTrie::Leaf(MappableCommand::Typable { + name, + args, + doc: label.to_string(), + })) } + Some(command) => Ok(KeyTrie::Leaf(command)), } } }