dsl: split ns trait
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
🪞👃🪞 2025-09-03 03:30:06 +03:00
parent c57117df9c
commit ff4d0c9db5
3 changed files with 33 additions and 103 deletions

View file

@ -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)
}
}