Skip to content

Commit

Permalink
Remove copy requirement from keymap
Browse files Browse the repository at this point in the history
  • Loading branch information
kdecay authored and rhelmot committed Jun 21, 2022
1 parent 74c620e commit ef03f43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions core/src/input/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ use crate::context::Context;
#[derive(Copy, Clone)]
pub struct KeymapEntry<T>
where
T: 'static + Copy + Clone + PartialEq + Send + Sync,
T: 'static + Clone + PartialEq + Send + Sync,
{
action: T,
on_action: fn(&mut Context),
}

impl<T> KeymapEntry<T>
where
T: 'static + Copy + Clone + PartialEq + Send + Sync,
T: 'static + Clone + PartialEq + Send + Sync,
{
/// Creates a new keymap entry.
///
Expand Down Expand Up @@ -50,7 +50,7 @@ where

impl<T> PartialEq for KeymapEntry<T>
where
T: 'static + Copy + Clone + PartialEq + Send + Sync,
T: 'static + Clone + PartialEq + Send + Sync,
{
fn eq(&self, other: &Self) -> bool {
self.action == other.action
Expand All @@ -59,7 +59,7 @@ where

impl<T> PartialEq<T> for KeymapEntry<T>
where
T: 'static + Copy + Clone + PartialEq + Send + Sync,
T: 'static + Clone + PartialEq + Send + Sync,
{
fn eq(&self, other: &T) -> bool {
self.action == *other
Expand Down
12 changes: 6 additions & 6 deletions core/src/input/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ use std::collections::HashMap;
/// This type is part of the prelude.
pub struct Keymap<T>
where
T: 'static + Copy + Clone + PartialEq + Send + Sync,
T: 'static + Clone + PartialEq + Send + Sync,
{
entries: HashMap<KeyChord, Vec<KeymapEntry<T>>>,
}

impl<T> Keymap<T>
where
T: 'static + Copy + Clone + PartialEq + Send + Sync,
T: 'static + Clone + PartialEq + Send + Sync,
{
/// Creates a new keymap.
///
Expand Down Expand Up @@ -171,11 +171,11 @@ where

impl<T> Model for Keymap<T>
where
T: 'static + Copy + Clone + PartialEq + Send + Sync,
T: 'static + Clone + PartialEq + Send + Sync,
{
fn event(&mut self, cx: &mut Context, event: &mut Event) {
event.map(|keymap_event, _| match keymap_event {
KeymapEvent::InsertAction(chord, entry) => self.insert(*chord, *entry),
KeymapEvent::InsertAction(chord, entry) => self.insert(*chord, entry.clone()),
KeymapEvent::RemoveAction(chord, action) => self.remove(chord, action),
});
event.map(|window_event, _| match window_event {
Expand All @@ -193,7 +193,7 @@ where

impl<T> From<Vec<(KeyChord, KeymapEntry<T>)>> for Keymap<T>
where
T: 'static + Copy + Clone + PartialEq + Send + Sync,
T: 'static + Clone + PartialEq + Send + Sync,
{
fn from(vec: Vec<(KeyChord, KeymapEntry<T>)>) -> Self {
let mut keymap = Self::new();
Expand All @@ -209,7 +209,7 @@ where
/// This type is part of the prelude.
pub enum KeymapEvent<T>
where
T: 'static + Copy + Clone + PartialEq + Send + Sync,
T: 'static + Clone + PartialEq + Send + Sync,
{
/// Inserts an entry into the [`Keymap`].
///
Expand Down

0 comments on commit ef03f43

Please sign in to comment.