dsl: reduce number of lifetime arguments
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-21 02:50:21 +03:00
parent 2048dd2263
commit 776cea6f1b
9 changed files with 126 additions and 108 deletions

View file

@ -5,13 +5,13 @@ use std::marker::PhantomData;
pub trait DslInput: Input { fn matches_dsl (&self, token: &str) -> bool; }
/// A pre-configured mapping of input events to commands.
pub trait KeyMap<'source, S, C: Namespace<'source, S> + Command<S>, I: DslInput> {
pub trait KeyMap<'source, S, C: Namespace<S> + Command<S>, I: DslInput> {
/// Try to find a command that matches the current input event.
fn keybind_resolve (&self, state: &S, input: &I) -> Perhaps<C>;
}
/// A [SourceIter] can be a [KeyMap].
impl<'source, S, C: Namespace<'source, S> + Command<S>, I: DslInput>
impl<'source, S, C: Namespace<S> + Command<S>, I: DslInput>
KeyMap<'source, S, C, I>
for SourceIter<'source> {
fn keybind_resolve (&self, state: &S, input: &I) -> Perhaps<C> {
@ -40,7 +40,7 @@ for SourceIter<'source> {
}
/// A [TokenIter] can be a [KeyMap].
impl<'source, S, C: Namespace<'source, S> + Command<S>, I: DslInput>
impl<'source, S, C: Namespace<S> + Command<S>, I: DslInput>
KeyMap<'source, S, C, I>
for TokenIter<'source> {
fn keybind_resolve (&self, state: &S, input: &I) -> Perhaps<C> {
@ -74,7 +74,7 @@ pub type InputCondition<'source, S> =
/// which may be made available subject to given conditions.
pub struct InputMap<'source,
S,
C: Command<S> + Namespace<'source, S>,
C: Command<S> + Namespace<S>,
I: DslInput,
M: KeyMap<'source, S, C, I>
> {
@ -84,7 +84,7 @@ pub struct InputMap<'source,
impl<'source,
S,
C: Command<S> + Namespace<'source, S>,
C: Command<S> + Namespace<S>,
I: DslInput,
M: KeyMap<'source, S, C, I>
> Default for InputMap<'source, S, C, I, M>{
@ -95,7 +95,7 @@ impl<'source,
impl<'source,
S,
C: Command<S> + Namespace<'source, S>,
C: Command<S> + Namespace<S>,
I: DslInput,
M: KeyMap<'source, S, C, I>
> InputMap<'source, S, C, I, M> {
@ -122,7 +122,7 @@ impl<'source,
impl<'source,
S,
C: Command<S> + Namespace<'source, S>,
C: Command<S> + Namespace<S>,
I: DslInput,
M: KeyMap<'source, S, C, I>
> std::fmt::Debug for InputMap<'source, S, C, I, M> {
@ -134,7 +134,7 @@ impl<'source,
/// An [InputMap] can be a [KeyMap].
impl<'source,
S,
C: Command<S> + Namespace<'source, S>,
C: Command<S> + Namespace<S>,
I: DslInput,
M: KeyMap<'source, S, C, I>
> KeyMap<'source, S, C, I> for InputMap<'source, S, C, I, M> {