diff --git a/src/action.rs b/src/action.rs index d859cd1..53464d1 100644 --- a/src/action.rs +++ b/src/action.rs @@ -138,8 +138,8 @@ impl Eq for HoldTapConfig {} #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub struct HoldTapAction where - T: 'static, - K: 'static, + T: 'static + Debug, + K: 'static + Debug, { /// The duration, in ticks (usually milliseconds) giving the /// difference between a hold and a tap. @@ -173,8 +173,8 @@ where #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum Action where - T: 'static, - K: 'static, + T: 'static + Debug, + K: 'static + Debug, { /// No operation action: just do nothing. NoOp, @@ -205,7 +205,7 @@ where /// manage with key events. Custom(T), } -impl Action { +impl Action { /// Gets the layer number if the action is the `Layer` action. pub fn layer(self) -> Option { match self { @@ -225,25 +225,41 @@ impl Action { /// A shortcut to create a `Action::KeyCode`, useful to create compact /// layout. -pub const fn k(kc: K) -> Action { +pub const fn k(kc: K) -> Action +where + T: Debug, + K: Debug, +{ Action::KeyCode(kc) } /// A shortcut to create a `Action::Layer`, useful to create compact /// layout. -pub const fn l(layer: usize) -> Action { +pub const fn l(layer: usize) -> Action +where + T: Debug, + K: Debug, +{ Action::Layer(layer) } /// A shortcut to create a `Action::DefaultLayer`, useful to create compact /// layout. -pub const fn d(layer: usize) -> Action { +pub const fn d(layer: usize) -> Action +where + T: Debug, + K: Debug, +{ Action::DefaultLayer(layer) } /// A shortcut to create a `Action::MultipleKeyCodes`, useful to /// create compact layout. -pub const fn m(kcs: &'static &'static [K]) -> Action { +pub const fn m(kcs: &'static &'static [K]) -> Action +where + T: Debug, + K: Debug, +{ Action::MultipleKeyCodes(kcs) } diff --git a/src/layout.rs b/src/layout.rs index fb1707c..e0f200c 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -49,6 +49,7 @@ pub use keyberon_macros::*; use crate::action::{Action, HoldTapAction, HoldTapConfig}; use crate::key_code::KeyCode; use arraydeque::ArrayDeque; +use core::fmt::Debug; use heapless::Vec; use State::*; @@ -82,8 +83,8 @@ pub struct Layout< T = core::convert::Infallible, K = KeyCode, > where - T: 'static, - K: 'static + Copy, + T: 'static + Debug, + K: 'static + Copy + Debug, { layers: &'static [[[Action; C]; R]; L], default_layer: usize, @@ -219,7 +220,7 @@ impl State { } #[derive(Debug)] -struct WaitingState { +struct WaitingState { coord: (u8, u8), timeout: u16, delay: u16, @@ -239,7 +240,11 @@ pub enum WaitingAction { NoOp, } -impl WaitingState { +impl WaitingState +where + T: 'static + Debug, + K: 'static + Debug, +{ fn tick(&mut self, stacked: &Stack) -> Option { self.timeout = self.timeout.saturating_sub(1); match self.config { @@ -335,8 +340,13 @@ impl TapHoldTracker { } } -impl - Layout +impl< + const C: usize, + const R: usize, + const L: usize, + T: 'static + Debug, + K: 'static + Copy + Debug, + > Layout { /// Creates a new `Layout` object. pub fn new(layers: &'static [[[Action; C]; R]; L]) -> Self {