From ef03f43c11b6e89604e0b589fce8f6eb64fd7c27 Mon Sep 17 00:00:00 2001 From: kdecay Date: Tue, 21 Jun 2022 18:16:07 +0200 Subject: [PATCH] Remove copy requirement from keymap --- core/src/input/entry.rs | 8 ++++---- core/src/input/keymap.rs | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/input/entry.rs b/core/src/input/entry.rs index 9f38857d0..223568d25 100644 --- a/core/src/input/entry.rs +++ b/core/src/input/entry.rs @@ -9,7 +9,7 @@ use crate::context::Context; #[derive(Copy, Clone)] pub struct KeymapEntry where - T: 'static + Copy + Clone + PartialEq + Send + Sync, + T: 'static + Clone + PartialEq + Send + Sync, { action: T, on_action: fn(&mut Context), @@ -17,7 +17,7 @@ where impl KeymapEntry where - T: 'static + Copy + Clone + PartialEq + Send + Sync, + T: 'static + Clone + PartialEq + Send + Sync, { /// Creates a new keymap entry. /// @@ -50,7 +50,7 @@ where impl PartialEq for KeymapEntry where - T: 'static + Copy + Clone + PartialEq + Send + Sync, + T: 'static + Clone + PartialEq + Send + Sync, { fn eq(&self, other: &Self) -> bool { self.action == other.action @@ -59,7 +59,7 @@ where impl PartialEq for KeymapEntry where - T: 'static + Copy + Clone + PartialEq + Send + Sync, + T: 'static + Clone + PartialEq + Send + Sync, { fn eq(&self, other: &T) -> bool { self.action == *other diff --git a/core/src/input/keymap.rs b/core/src/input/keymap.rs index 890bc005b..32ab034b1 100644 --- a/core/src/input/keymap.rs +++ b/core/src/input/keymap.rs @@ -46,14 +46,14 @@ use std::collections::HashMap; /// This type is part of the prelude. pub struct Keymap where - T: 'static + Copy + Clone + PartialEq + Send + Sync, + T: 'static + Clone + PartialEq + Send + Sync, { entries: HashMap>>, } impl Keymap where - T: 'static + Copy + Clone + PartialEq + Send + Sync, + T: 'static + Clone + PartialEq + Send + Sync, { /// Creates a new keymap. /// @@ -171,11 +171,11 @@ where impl Model for Keymap 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 { @@ -193,7 +193,7 @@ where impl From)>> for Keymap where - T: 'static + Copy + Clone + PartialEq + Send + Sync, + T: 'static + Clone + PartialEq + Send + Sync, { fn from(vec: Vec<(KeyChord, KeymapEntry)>) -> Self { let mut keymap = Self::new(); @@ -209,7 +209,7 @@ where /// This type is part of the prelude. pub enum KeymapEvent where - T: 'static + Copy + Clone + PartialEq + Send + Sync, + T: 'static + Clone + PartialEq + Send + Sync, { /// Inserts an entry into the [`Keymap`]. ///