mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
input_dsl: expose InputMap layers; add From<SourceIter> for TokenIter
This commit is contained in:
parent
4ec51d5b69
commit
119d5c35f0
2 changed files with 11 additions and 2 deletions
|
|
@ -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<SourceIter<'a>> 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue