Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace macros to normal closure or function in translate/function.rs #328

Closed
panarch opened this issue Aug 26, 2021 · 1 comment
Closed
Assignees

Comments

@panarch
Copy link
Member

panarch commented Aug 26, 2021

There are three macros aggr, func_with_one_arg and func_with_two_arg which can be replaced by normal Rust functions or closures.

macro_rules! aggr {
($aggregate: expr) => {{
check_len(name, args.len(), 1)?;
translate_expr(args[0])
.map($aggregate)
.map(Box::new)
.map(Expr::Aggregate)
}};
}
macro_rules! func_with_one_arg {
($func: expr) => {{
check_len(name, args.len(), 1)?;
translate_expr(args[0])
.map($func)
.map(Box::new)
.map(Expr::Function)
}};
}
macro_rules! func_with_two_arg {
($func: ident) => {{
check_len_range(stringify!($func).to_owned(), args.len(), 1, 2)?;
let expr = translate_expr(args[0])?;
let chars = if args.len() == 1 {
None
} else {
Some(translate_expr(args[1])?)
};
Ok(Expr::Function(Box::new(Function::$func { expr, chars })))
}};
}

@devil-k
Copy link
Contributor

devil-k commented Aug 26, 2021

thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants