Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- macro_rules! decorate {
- (CALL $decorator:ident, $funcname:ident($($args:ident: $typ:ty),*) -> $ret:ty $implementation:block, $($input:expr),*) => {{
- let f = |$($args: $typ),*| -> $ret {
- $implementation
- };
- $decorator(f, $($input),*)
- }}
- }
- fn Foo<F: Fn(i32) -> i32>(func: F, n: i32) -> impl Fn() -> i32 {
- println!("calling it!");
- move || func(n)
- }
- fn main() {
- let t = decorate!(CALL Foo, bar(p: i32) -> i32 {
- p * 10
- }, 10);
- }
Add Comment
Please, Sign In to add comment