use crate::context::EventContext;
#[derive(Copy, Clone)]
pub struct KeymapEntry<T>
where
T: 'static + Clone + PartialEq + Send + Sync,
{
action: T,
on_action: fn(&mut EventContext),
}
impl<T> KeymapEntry<T>
where
T: 'static + Clone + PartialEq + Send + Sync,
{
pub fn new(action: T, on_action: fn(&mut EventContext)) -> Self {
Self { action, on_action }
}
pub fn action(&self) -> &T {
&self.action
}
pub fn on_action(&self) -> &fn(&mut EventContext) {
&self.on_action
}
}
impl<T> PartialEq for KeymapEntry<T>
where
T: 'static + Clone + PartialEq + Send + Sync,
{
fn eq(&self, other: &Self) -> bool {
self.action == other.action
}
}
impl<T> PartialEq<T> for KeymapEntry<T>
where
T: 'static + Clone + PartialEq + Send + Sync,
{
fn eq(&self, other: &T) -> bool {
self.action == *other
}
}