Guest User

Untitled

a guest
May 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. macro_rules! decorate {
  2. (CALL $decorator:ident, $funcname:ident($($args:ident: $typ:ty),*) -> $ret:ty $implementation:block, $($input:expr),*) => {{
  3. let f = |$($args: $typ),*| -> $ret {
  4. $implementation
  5. };
  6.  
  7. $decorator(f, $($input),*)
  8. }}
  9. }
  10.  
  11.  
  12. fn Foo<F: Fn(i32) -> i32>(func: F, n: i32) -> impl Fn() -> i32 {
  13. println!("calling it!");
  14.  
  15. move || func(n)
  16. }
  17.  
  18.  
  19. fn main() {
  20. let t = decorate!(CALL Foo, bar(p: i32) -> i32 {
  21. p * 10
  22. }, 10);
  23.  
  24. }
Add Comment
Please, Sign In to add comment