Last active
August 29, 2015 13:57
-
-
Save shadowmint/9542616 to your computer and use it in GitHub Desktop.
Crate with a macro
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
#[feature(macro_rules)]; | |
#[crate_id = "junk#0.1"]; | |
#[no_mangle] | |
pub fn dothing(a: int, b:int) -> int { | |
return a + b; | |
} | |
#[macro_escape] | |
#[macro_export] | |
macro_rules! trace( | |
($($arg:tt)*) => ( | |
{ let x = ::std::io::stdout().write_line(format_args!(::std::fmt::format, $($arg)*)); println!("{}", x); } | |
); | |
) | |
#[test] | |
fn test_trace_macro() { | |
trace!("Hello World {} {}", 1, 2); | |
} |
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
#[feature(globs)]; | |
#[feature(phase)]; | |
#[phase(syntax)] | |
extern crate junk; | |
use junk; | |
fn main() { | |
trace!("HI"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment