mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
removing engine generic from transforms
This commit is contained in:
parent
452bdf9598
commit
a949117017
8 changed files with 184 additions and 184 deletions
|
|
@ -30,7 +30,7 @@ macro_rules! iterate {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[derive(Clone, PartialEq)] pub struct TokensIterator<'a>(&'a str);
|
||||
#[derive(Copy, Clone, PartialEq)] pub struct TokensIterator<'a>(&'a str);
|
||||
impl<'a> Iterator for TokensIterator<'a> {
|
||||
type Item = TokenResult<'a>;
|
||||
fn next (&mut self) -> Option<TokenResult<'a>> { self.next_mut().map(|(result, _)|result) }
|
||||
|
|
@ -159,14 +159,14 @@ pub trait Atom: Sized {
|
|||
fn text (&self) -> &str;
|
||||
fn num (&self) -> usize;
|
||||
}
|
||||
#[derive(Clone, PartialEq)] pub enum RefAtom<'a> {
|
||||
#[derive(Copy, Clone, PartialEq)] pub enum RefAtom<'a> {
|
||||
Num(usize),
|
||||
Sym(&'a str),
|
||||
Key(&'a str),
|
||||
Exp(RefAtomsIterator<'a>),
|
||||
}
|
||||
type RefAtomResult<'a> = Result<RefAtom<'a>, ParseError>;
|
||||
#[derive(Clone, PartialEq)] pub struct RefAtomsIterator<'a>(TokensIterator<'a>);
|
||||
#[derive(Copy, Clone, PartialEq)] pub struct RefAtomsIterator<'a>(TokensIterator<'a>);
|
||||
impl<'a> Iterator for RefAtomsIterator<'a> {
|
||||
type Item = RefAtomResult<'a>;
|
||||
fn next (&mut self) -> Option<RefAtomResult<'a>> {
|
||||
|
|
@ -398,17 +398,9 @@ impl<'a, T: Context<'a, U>, U> Context<'a, U> for Option<T> {
|
|||
#[macro_export] macro_rules! try_delegate {
|
||||
($s:ident, $atom:expr, $T:ty) => {
|
||||
if let [head, tail @ ..] = $atom.as_slice() {
|
||||
if let Some(value) = <$T>::try_from_atom($s, head, tail) {
|
||||
if let Some(value) = <$T>::try_from_atoms($s, head, tail) {
|
||||
return Some(value.boxed())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub trait TryFromAtom<'a, T>: Sized {
|
||||
fn try_from_atom (state: &'a T, head: &impl Atom, tail: &'a [impl Atom]) ->
|
||||
Option<Self>;
|
||||
}
|
||||
pub trait TryIntoAtom<'a, T>: Sized {
|
||||
fn try_from_atom (state: &'a T, head: &impl Atom, tail: &'a [impl Atom]) ->
|
||||
Option<Self>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue