gluing
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-08-10 03:53:46 +03:00
parent f2d6e7724b
commit b991a49ad7
3 changed files with 106 additions and 87 deletions

View file

@ -1,19 +1,24 @@
use crate::*;
macro_rules!dsl_sym(
pub struct DslNs<'t, T: 't>(pub &'t [(&'t str, T)]);
pub trait DslSymNs<'t, T: 't>: 't { const NS: DslNs<'t, fn (&'t Self)->T>; }
#[macro_export] macro_rules! dsl_sym (
(|$state:ident:$State:ty| -> $type:ty {$($lit:literal => $exp:expr),* $(,)?})=>{
impl<'t> DslSymNs<'t, $type> for $State {
const NS: DslNs<'t, fn (&'t $State)->$type> =
DslNs(&[$(($lit, |$state: &$State|$exp)),*]); } });
pub trait DslSymNs<'t, T: 't>: 't {
const NS: DslNs<'t, fn (&'t Self)->T>;
}
pub struct DslNs<'t, T: 't>(pub &'t [(&'t str, T)]);
pub trait DslExpNs<'t, T: 't>: 't { const NS: DslNs<'t, fn (&'t Self, &str)->T>; }
#[macro_export] macro_rules! dsl_exp (
(|$state:ident:$State:ty|->$type:ty { $(
[$key:literal $(/ $sub:ident: $Sub:ty)? $(, $arg:ident $(?)? :$argtype:ty)*] => $body:expr
),* $(,)? }) => {
impl<'t> DslExpNs<'t, $type> for $State {
const NS: DslNs<'t, fn (&'t $State, &str)->$type> =
DslNs(&[]); } });
pub type DslCb = fn (&App) -> Box<dyn Render<TuiOut>>;
impl<'t, D: Dsl> std::ops::Index<D> for DslNs<'t, DslCb> {
type Output = DslCb;
fn index (&self, index: D) -> &Self::Output {