mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
dsl: macro dsl_for_each -> method each
This commit is contained in:
parent
a601d3d806
commit
9ccd7e5c69
2 changed files with 8 additions and 18 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue