Last active
December 20, 2015 22:49
-
-
Save orenbenkiki/6208391 to your computer and use it in GitHub Desktop.
macro_export not working?
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
mod code { | |
use macros; // compiler warning: unused import :-( | |
#[test] | |
fn asserts() { | |
assert_eq!(1, 1); | |
assert_ne!(1, 2); // compiler error: macro undefined :-( | |
} | |
} |
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
#[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; |
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_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