Skip to content

Commit

Permalink
Replace SmallVec with Vec
Browse files Browse the repository at this point in the history
  • Loading branch information
lopopolo committed Apr 10, 2022
1 parent 583b73f commit 9c46ae4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions examples/custom_key_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use smallvec::smallvec;
use std::borrow::Cow::{self, Borrowed, Owned};

use rustyline::highlight::Highlighter;
Expand Down Expand Up @@ -105,7 +104,7 @@ fn main() -> Result<()> {
EventHandler::Conditional(Box::new(TabEventHandler)),
);
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent::ctrl('X'), KeyEvent::ctrl('E')]),
Event::KeySeq(vec![KeyEvent::ctrl('X'), KeyEvent::ctrl('E')]),
EventHandler::Simple(Cmd::Suspend), // TODO external editor
);

Expand Down
9 changes: 3 additions & 6 deletions src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
};

use radix_trie::TrieKey;
use smallvec::{smallvec, SmallVec};

/// Input event
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand All @@ -13,8 +12,7 @@ pub enum Event {
/// Useful if you want to filter out some keys.
Any,
/// Key sequence
// TODO Validate 2 ?
KeySeq(SmallVec<[KeyEvent; 2]>),
KeySeq(Vec<KeyEvent>),
/// TODO Mouse event
Mouse(),
}
Expand Down Expand Up @@ -43,7 +41,7 @@ impl Event {

impl From<KeyEvent> for Event {
fn from(k: KeyEvent) -> Event {
Event::KeySeq(smallvec![k])
Event::KeySeq(vec![k])
}
}

Expand Down Expand Up @@ -219,12 +217,11 @@ mod test {
use super::{Event, EventHandler};
use crate::{Cmd, KeyCode, KeyEvent, Modifiers};
use radix_trie::Trie;
use smallvec::smallvec;

#[test]
fn encode() {
let mut trie = Trie::new();
let evt = Event::KeySeq(smallvec![KeyEvent::ctrl('X'), KeyEvent::ctrl('E')]);
let evt = Event::KeySeq(vec![KeyEvent::ctrl('X'), KeyEvent::ctrl('E')]);
trie.insert(evt.clone(), EventHandler::from(Cmd::Noop));
let prefix = Event::from(KeyEvent::ctrl('X'));
let subtrie = trie.get_raw_descendant(&prefix);
Expand Down

0 comments on commit 9c46ae4

Please sign in to comment.