diff --git a/dsl/src/dsl_iter.rs b/dsl/src/dsl_iter.rs index de9fe7a..0a94b3c 100644 --- a/dsl/src/dsl_iter.rs +++ b/dsl/src/dsl_iter.rs @@ -14,7 +14,10 @@ use crate::*; /// Provides a native [Iterator] API over the [ConstIntoIter] [SourceIter] /// [TokenIter::next] returns just the [Token] and mutates `self`, /// instead of returning an updated version of the struct as [SourceIter::next] does. -#[derive(Copy, Clone, Debug, Default, PartialEq)] pub struct TokenIter<'a>(pub SourceIter<'a>); +#[derive(Copy, Clone, Debug, Default, PartialEq)] pub struct TokenIter<'a>( + pub SourceIter<'a> +); + impl<'a> TokenIter<'a> { pub const fn new (source: &'a str) -> Self { Self(SourceIter::new(source)) @@ -31,6 +34,12 @@ impl<'a> Iterator for TokenIter<'a> { } } +impl<'a> From> for TokenIter<'a> { + fn from (source: SourceIter<'a>) -> Self{ + Self(source) + } +} + /// Owns a reference to the source text. /// [SourceIter::next] emits subsequent pairs of: /// * a [Token] and diff --git a/input/src/input_dsl.rs b/input/src/input_dsl.rs index 3a79fd4..bcc6067 100644 --- a/input/src/input_dsl.rs +++ b/input/src/input_dsl.rs @@ -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. pub struct InputMap<'a, S, C: DslCommand<'a, S>, I: DslInput, M: KeyMap<'a, S, C, I> + Send + Sync> { __: &'a PhantomData<(S, C, I)>, - layers: Vec<( + pub layers: Vec<( fn(&S)->bool, M )>,