Skip to content

Instantly share code, notes, and snippets.

@orenbenkiki
Last active December 20, 2015 22:49
Show Gist options
  • Save orenbenkiki/6208391 to your computer and use it in GitHub Desktop.
Save orenbenkiki/6208391 to your computer and use it in GitHub Desktop.
macro_export not working?
mod code {
use macros; // compiler warning: unused import :-(
#[test]
fn asserts() {
assert_eq!(1, 1);
assert_ne!(1, 2); // compiler error: macro undefined :-(
}
}
#[link(name = "junk", vers = "0.0")];
#[crate_type = "lib"];
#[warn(non_camel_case_types)];
#[warn(non_uppercase_statics)];
#[warn(unnecessary_qualification)];
extern mod std;
extern mod extra;
pub mod code;
pub mod macros;
#[macro_escape]
mod macros {
// Same as the `assert_eq!` macro, but expect the values to be different
// instead of the same.
macro_rules! assert_ne (
($given:expr , $unexpected:expr) => (
{
let given_val = $given;
let unexpected_val = $unexpected;
// Check both directions of (in)equality....
if (given_val == unexpected_val) || (unexpected_val == given_val) {
fail!("assertion failed: `!((left == right) || (right == left))` (left: `%?`, right: `%?`)",
given_val, unexpected_val);
}
}
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment