mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
This commit is contained in:
parent
c57117df9c
commit
ff4d0c9db5
3 changed files with 33 additions and 103 deletions
|
|
@ -68,3 +68,18 @@ dsl_type!(DslExpr {
|
|||
($name, get)
|
||||
}),* )? ];
|
||||
});
|
||||
|
||||
pub trait DslNsExprs<'a, T: 'a>: 'a {
|
||||
/// Known expressions.
|
||||
const EXPRS: DslExprs<'a, Self, T> = &[];
|
||||
/// Resolve an expression if known.
|
||||
fn from_expr (&'a self, dsl: impl DslExpr + 'a) -> Perhaps<T> {
|
||||
let head = dsl.head()?;
|
||||
for (key, get) in Self::EXPRS.iter() {
|
||||
if Some(*key) == head {
|
||||
return get(self, dsl.tail()?.unwrap_or(""))
|
||||
}
|
||||
}
|
||||
return Ok(None)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue