@@ -300,7 +300,7 @@ impl KeyTrie {
300300}
301301
302302#[derive(Debug, Clone, PartialEq)]
303−pub enum KeymapResultKind {
303+pub enum KeymapResult {
304304 /// Needs more keys to execute a command. Contains valid keys for next keystroke.
305305 Pending(KeyTrieNode),
306306 Matched(MappableCommand),
@@ -313,20 +313,6 @@ pub enum KeymapResultKind {
313313 Cancelled(Vec<KeyEvent>),
314314}
315315
316−/// Returned after looking up a key in [`Keymap`]. The `sticky` field has a
317−/// reference to the sticky node if one is currently active.
318−#[derive(Debug)]
319−pub struct KeymapResult<'a> {
320− pub kind: KeymapResultKind,
321− pub sticky: Option<&'a KeyTrieNode>,
322−}
323−
324−impl<'a> KeymapResult<'a> {
325− pub fn new(kind: KeymapResultKind, sticky: Option<&'a KeyTrieNode>) -> Self {
326− Self { kind, sticky }
327− }
328−}
329−
330316#[derive(Debug, Clone, PartialEq, Deserialize)]
331317#[serde(transparent)]
332318pub struct Keymap {
@@ -437,11 +423,8 @@ impl Keymaps {
437423
438424 if key!(Esc) == key {
439425 if !self.state.is_empty() {
440− return KeymapResult::new(
441− // Note that Esc is not included here
442− KeymapResultKind::Cancelled(self.state.drain(..).collect()),
443− self.sticky(),
444− );
426+ // Note that Esc is not included here
427+ return KeymapResult::Cancelled(self.state.drain(..).collect());
445428 }
446429 self.sticky = None;
447430 }
@@ -454,15 +437,12 @@ impl Keymaps {
454437
455438 let trie = match trie_node.search(&[*first]) {
456439 Some(KeyTrie::Leaf(ref cmd)) => {
457− return KeymapResult::new(KeymapResultKind::Matched(cmd.clone()), self.sticky())
440+ return KeymapResult::Matched(cmd.clone());
458441 }
459442 Some(KeyTrie::Sequence(ref cmds)) => {
460− return KeymapResult::new(
461− KeymapResultKind::MatchedSequence(cmds.clone()),
462− self.sticky(),
463− )
443+ return KeymapResult::MatchedSequence(cmds.clone());
464444 }
465− None => return KeymapResult::new(KeymapResultKind::NotFound, self.sticky()),
445+ None => return KeymapResult::NotFound,
466446 Some(t) => t,
467447 };
468448
@@ -473,23 +453,17 @@ impl Keymaps {
473453 self.state.clear();
474454 self.sticky = Some(map.clone());
475455 }
476− KeymapResult::new(KeymapResultKind::Pending(map.clone()), self.sticky())
456+ KeymapResult::Pending(map.clone())
477457 }
478458 Some(&KeyTrie::Leaf(ref cmd)) => {
479459 self.state.clear();
480− return KeymapResult::new(KeymapResultKind::Matched(cmd.clone()), self.sticky());
460+ KeymapResult::Matched(cmd.clone())
481461 }
482462 Some(&KeyTrie::Sequence(ref cmds)) => {
483463 self.state.clear();
484− KeymapResult::new(
485− KeymapResultKind::MatchedSequence(cmds.clone()),
486− self.sticky(),
487− )
464+ KeymapResult::MatchedSequence(cmds.clone())
488465 }
489− None => KeymapResult::new(
490− KeymapResultKind::Cancelled(self.state.drain(..).collect()),
491− self.sticky(),
492− ),
466+ None => KeymapResult::Cancelled(self.state.drain(..).collect()),
493467 }
494468 }
495469}
@@ -901,19 +875,19 @@ mod tests {
901875
902876 let keymap = &mut merged_config.keys;
903877 assert_eq!(
904− keymap.get(Mode::Normal, key!('i')).kind,
905− KeymapResultKind::Matched(MappableCommand::normal_mode),
878+ keymap.get(Mode::Normal, key!('i')),
879+ KeymapResult::Matched(MappableCommand::normal_mode),
906880 "Leaf should replace leaf"
907881 );
908882 assert_eq!(
909− keymap.get(Mode::Normal, key!('无')).kind,
910− KeymapResultKind::Matched(MappableCommand::insert_mode),
883+ keymap.get(Mode::Normal, key!('无')),
884+ KeymapResult::Matched(MappableCommand::insert_mode),
911885 "New leaf should be present in merged keymap"
912886 );
913887 // Assumes that z is a node in the default keymap
914888 assert_eq!(
915− keymap.get(Mode::Normal, key!('z')).kind,
916− KeymapResultKind::Matched(MappableCommand::jump_backward),
889+ keymap.get(Mode::Normal, key!('z')),
890+ KeymapResult::Matched(MappableCommand::jump_backward),
917891 "Leaf should replace node"
918892 );
919893