dsl: macro dsl_for_each -> method each

This commit is contained in:
🪞👃🪞 2025-08-03 19:36:01 +03:00
parent a601d3d806
commit 9ccd7e5c69
2 changed files with 8 additions and 18 deletions

View file

@ -1,5 +1,4 @@
use crate::*;
/// Event source
pub trait Input: Sized {
/// Type of input event
@ -13,13 +12,11 @@ pub trait Input: Sized {
/// Mark component as done
fn done (&self);
}
flex_trait_mut!(Handle <E: Input> {
fn handle (&mut self, _input: &E) -> Perhaps<E::Handled> {
Ok(None)
}
});
pub trait Command<S>: Send + Sync + Sized {
fn execute (self, state: &mut S) -> Perhaps<Self>;
fn delegate <T> (self, state: &mut S, wrap: impl Fn(Self)->T) -> Perhaps<T>
@ -28,7 +25,6 @@ pub trait Command<S>: Send + Sync + Sized {
Ok(self.execute(state)?.map(wrap))
}
}
impl<S, T: Command<S>> Command<S> for Option<T> {
fn execute (self, _: &mut S) -> Perhaps<Self> {
Ok(None)