summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Oram <dev@mitmaro.ca>2021-06-27 21:18:11 -0230
committerTim Oram <dev@mitmaro.ca>2021-07-05 16:27:53 -0230
commit5ea9ccfdf79c4b221d788d47f3aa076d210a966f (patch)
tree43ee3aaf55066020a431c7a121c99ed73f343df3
parent88faf728222974afa17e5517bc386ab46d948867 (diff)
Add inline to functions
-rw-r--r--src/input/src/event.rs4
-rw-r--r--src/input/src/event_handler.rs4
-rw-r--r--src/input/src/input_options.rs5
-rw-r--r--src/input/src/key_bindings.rs1
-rw-r--r--src/input/src/lib.rs3
-rw-r--r--src/input/src/testutil.rs3
6 files changed, 17 insertions, 3 deletions
diff --git a/src/input/src/event.rs b/src/input/src/event.rs
index 5366b6f..8e4d1c2 100644
--- a/src/input/src/event.rs
+++ b/src/input/src/event.rs
@@ -13,6 +13,7 @@ pub enum Event {
}
impl From<crossterm::event::Event> for Event {
+ #[inline]
fn from(event: crossterm::event::Event) -> Self {
match event {
crossterm::event::Event::Key(event) => Self::Key(event),
@@ -23,12 +24,14 @@ impl From<crossterm::event::Event> for Event {
}
impl From<MetaEvent> for Event {
+ #[inline]
fn from(event: MetaEvent) -> Self {
Self::Meta(event)
}
}
impl From<KeyCode> for Event {
+ #[inline]
fn from(code: KeyCode) -> Self {
Self::Key(KeyEvent {
code,
@@ -38,6 +41,7 @@ impl From<KeyCode> for Event {
}
impl From<char> for Event {
+ #[inline]
fn from(c: char) -> Self {
Self::Key(KeyEvent {
code: KeyCode::Char(c),
diff --git a/src/input/src/event_handler.rs b/src/input/src/event_handler.rs
index 840fa6e..b66378f 100644
--- a/src/input/src/event_handler.rs
+++ b/src/input/src/event_handler.rs
@@ -13,6 +13,7 @@ pub struct EventHandler {
}
impl EventHandler {
+ #[inline]
pub fn new<F: 'static>(event_provider: F, key_bindings: KeyBindings) -> Self
where F: Fn() -> Result<Option<crossterm::event::Event>> {
Self {
@@ -22,6 +23,7 @@ impl EventHandler {
}
}
+ #[inline]
pub fn poll_event(&self) -> Event {
if let Some(event) = self.event_queue.borrow_mut().pop_front() {
event
@@ -34,10 +36,12 @@ impl EventHandler {
}
}
+ #[inline]
pub fn push_event(&self, event: Event) {
self.event_queue.borrow_mut().push_back(event);
}
+ #[inline]
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn read_event<F>(&self, input_options: &InputOptions, callback: F) -> Event
where F: FnOnce(Event, &KeyBindings) -> Event {
diff --git a/src/input/src/input_options.rs b/src/input/src/input_options.rs
index 5215744..351f888 100644
--- a/src/input/src/input_options.rs
+++ b/src/input/src/input_options.rs
@@ -7,6 +7,7 @@ pub struct InputOptions {
}
impl InputOptions {
+ #[inline]
#[must_use]
pub const fn new() -> Self {
Self {
@@ -17,24 +18,28 @@ impl InputOptions {
}
}
+ #[inline]
#[must_use]
pub const fn help(mut self, val: bool) -> Self {
self.help = val;
self
}
+ #[inline]
#[must_use]
pub const fn movement(mut self, val: bool) -> Self {
self.movement = val;
self
}
+ #[inline]
#[must_use]
pub const fn resize(mut self, val: bool) -> Self {
self.resize = val;
self
}
+ #[inline]
#[must_use]
pub const fn undo_redo(mut self, val: bool) -> Self {
self.undo_redo = val;
diff --git a/src/input/src/key_bindings.rs b/src/input/src/key_bindings.rs
index 980a1c4..583561a 100644
--- a/src/input/src/key_bindings.rs
+++ b/src/input/src/key_bindings.rs
@@ -87,6 +87,7 @@ fn map_keybindings(bindings: &[String]) -> Vec<Event> {
}
impl KeyBindings {
+ #[inline]
#[must_use]
pub fn new(key_bindings: &config::KeyBindings) -> Self {
Self {
diff --git a/src/input/src/lib.rs b/src/input/src/lib.rs
index 91b98bc..1998def 100644
--- a/src/input/src/lib.rs
+++ b/src/input/src/lib.rs
@@ -66,10 +66,7 @@
rustdoc::missing_crate_level_docs,
clippy::else_if_without_else,
clippy::exhaustive_structs,
- clippy::implicit_return,
clippy::indexing_slicing,
- clippy::missing_docs_in_private_items,
- clippy::missing_inline_in_public_items,
clippy::struct_excessive_bools,
clippy::unwrap_used,
clippy::wildcard_enum_match_arm
diff --git a/src/input/src/testutil.rs b/src/input/src/testutil.rs
index 26b93e4..0403488 100644
--- a/src/input/src/testutil.rs
+++ b/src/input/src/testutil.rs
@@ -82,6 +82,7 @@ fn map_event_to_crossterm(event: Event) -> crossterm::event::Event {
}
}
+#[inline]
#[must_use]
pub fn create_test_keybindings() -> KeyBindings {
KeyBindings {
@@ -137,6 +138,7 @@ pub struct TestContext {
}
impl TestContext {
+ #[inline]
pub fn for_each_event<C, T>(&self, mut callback: C) -> Vec<T>
where C: FnMut(&EventHandler) -> T {
let mut results = vec![];
@@ -147,6 +149,7 @@ impl TestContext {
}
}
+#[inline]
pub fn with_event_handler<C>(events: &[Event], callback: C)
where C: FnOnce(TestContext) {
let crossterm_events = RefCell::new(