Created
November 27, 2014 12:08
-
-
Save bvssvni/d7a02cc89523be28b4c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
current! { | |
FOO: bar | |
=> { | |
print_text(); | |
print_text(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<current macros>:8:41: 8:43 error: expected ident, found => | |
<current macros>:8 current!{ $($TAIL: $tail),* => $f:expr } | |
^~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_export] | |
macro_rules! current { | |
(=> $f:expr) => {{ | |
$f | |
}}; | |
($HEAD:ident: $head:ident $(,$TAIL:ident: $tail:ident)* => $f:expr) => {{ | |
let $head = RefCell::new($head); | |
$HEAD.set(&$head, || { | |
current!{ $($TAIL: $tail),* => $f:expr } | |
}) | |
}}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment