mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
Compare commits
No commits in common. "44ebe17c665b3a65e7a3a0020eff290093fc7ed2" and "4ec51d5b694c14ccf617ec4538da04089b17ab92" have entirely different histories.
44ebe17c66
...
4ec51d5b69
2 changed files with 36 additions and 11 deletions
|
|
@ -14,10 +14,7 @@ use crate::*;
|
||||||
/// Provides a native [Iterator] API over the [ConstIntoIter] [SourceIter]
|
/// Provides a native [Iterator] API over the [ConstIntoIter] [SourceIter]
|
||||||
/// [TokenIter::next] returns just the [Token] and mutates `self`,
|
/// [TokenIter::next] returns just the [Token] and mutates `self`,
|
||||||
/// instead of returning an updated version of the struct as [SourceIter::next] does.
|
/// instead of returning an updated version of the struct as [SourceIter::next] does.
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq)] pub struct TokenIter<'a>(
|
#[derive(Copy, Clone, Debug, Default, PartialEq)] pub struct TokenIter<'a>(pub SourceIter<'a>);
|
||||||
pub SourceIter<'a>
|
|
||||||
);
|
|
||||||
|
|
||||||
impl<'a> TokenIter<'a> {
|
impl<'a> TokenIter<'a> {
|
||||||
pub const fn new (source: &'a str) -> Self {
|
pub const fn new (source: &'a str) -> Self {
|
||||||
Self(SourceIter::new(source))
|
Self(SourceIter::new(source))
|
||||||
|
|
@ -34,12 +31,6 @@ impl<'a> Iterator for TokenIter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<SourceIter<'a>> for TokenIter<'a> {
|
|
||||||
fn from (source: SourceIter<'a>) -> Self{
|
|
||||||
Self(source)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Owns a reference to the source text.
|
/// Owns a reference to the source text.
|
||||||
/// [SourceIter::next] emits subsequent pairs of:
|
/// [SourceIter::next] emits subsequent pairs of:
|
||||||
/// * a [Token] and
|
/// * a [Token] and
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ impl<'a, S, C: DslCommand<'a, S>, I: DslInput> KeyMap<'a, S, C, I> for TokenIter
|
||||||
/// which may be made available subject to given conditions.
|
/// which may be made available subject to given conditions.
|
||||||
pub struct InputMap<'a, S, C: DslCommand<'a, S>, I: DslInput, M: KeyMap<'a, S, C, I> + Send + Sync> {
|
pub struct InputMap<'a, S, C: DslCommand<'a, S>, I: DslInput, M: KeyMap<'a, S, C, I> + Send + Sync> {
|
||||||
__: &'a PhantomData<(S, C, I)>,
|
__: &'a PhantomData<(S, C, I)>,
|
||||||
pub layers: Vec<(
|
layers: Vec<(
|
||||||
fn(&S)->bool,
|
fn(&S)->bool,
|
||||||
M
|
M
|
||||||
)>,
|
)>,
|
||||||
|
|
@ -152,3 +152,37 @@ where
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fn handle <C> (&self, state: &mut T, input: &U) -> Perhaps<bool> {
|
||||||
|
//for layer in self.layers.iter() {
|
||||||
|
//if !(layer.0)(state) {
|
||||||
|
//continue
|
||||||
|
//}
|
||||||
|
//let command: Option<C> = SourceIter(layer.1).command::<_, _, _>(state, input);
|
||||||
|
//if let Some(command) = command {
|
||||||
|
//if let Some(undo) = command.execute(state)? {
|
||||||
|
////app.history.push(undo);
|
||||||
|
//}
|
||||||
|
//return Ok(Some(true))
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
//Ok(None)
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
//fn layer (mut self, keymap: &'static str) -> Self {
|
||||||
|
//self.add_layer(keymap);
|
||||||
|
//self
|
||||||
|
//}
|
||||||
|
//fn layer_if (mut self, condition: impl Fn(&T)->bool + 'static, keymap: &'static str) -> Self {
|
||||||
|
//self.add_layer_if(condition, keymap);
|
||||||
|
//self
|
||||||
|
//}
|
||||||
|
//fn add_layer (&mut self, keymap: &'static str) -> &mut Self {
|
||||||
|
//self.layers.push((Box::new(|_|true), keymap));
|
||||||
|
//self
|
||||||
|
//}
|
||||||
|
//fn add_layer_if (&mut self, condition: impl Fn(&T)->bool + 'static, keymap: &'static str) -> &mut Self {
|
||||||
|
//self.layers.push((Box::new(condition), keymap));
|
||||||
|
//self
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue