Skip to content

Instantly share code, notes, and snippets.

@shadowmint
Last active August 29, 2015 13:57
Show Gist options
  • Save shadowmint/9542616 to your computer and use it in GitHub Desktop.
Save shadowmint/9542616 to your computer and use it in GitHub Desktop.
Crate with a macro
#[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);
}
#[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