Added support for defining macros in Rust within the macro system

Also fixed a lot of bugs
This commit is contained in:
2025-09-30 21:23:16 +02:00
parent 7971a2b4eb
commit b77653f841
52 changed files with 849 additions and 502 deletions

View File

@@ -43,7 +43,7 @@ struct FunRecord {
fun: Rc<dyn FunCB>,
}
async fn process_args<I, O, F: ExprFunc<I, O>>(
fn process_args<I, O, F: ExprFunc<I, O>>(
debug: impl AsRef<str> + Clone + 'static,
f: F,
) -> FunRecord {
@@ -83,7 +83,7 @@ impl Fun {
let record = if let Some(record) = fung.get(&path) {
record.clone()
} else {
let record = process_args(path.to_string(), f).await;
let record = process_args(path.to_string(), f);
fung.insert(path.clone(), record.clone());
record
};
@@ -134,11 +134,8 @@ pub struct Lambda {
record: FunRecord,
}
impl Lambda {
pub async fn new<I, O, F: ExprFunc<I, O>>(
debug: impl AsRef<str> + Clone + 'static,
f: F,
) -> Self {
Self { args: vec![], record: process_args(debug, f).await }
pub fn new<I, O, F: ExprFunc<I, O>>(debug: impl AsRef<str> + Clone + 'static, f: F) -> Self {
Self { args: vec![], record: process_args(debug, f) }
}
}
impl Atomic for Lambda {
@@ -176,7 +173,7 @@ mod expr_func_derives {
impl<
$($t: TryFromExpr + 'static, )*
Out: ToExpr,
Func: AsyncFn($($t,)*) -> Out + Clone + Send + Sync + 'static
Func: AsyncFn($($t,)*) -> Out + Clone + 'static
> ExprFunc<($($t,)*), Out> for Func {
fn argtyps() -> &'static [TypeId] {
static STORE: OnceLock<Vec<TypeId>> = OnceLock::new();