I'm sure this is trivial to do, but I can't seem to make it work.
I've looked at http://doc.rust-lang.org/book/advanced-macros.html#scoping-and-macro-import/export, and I appreciate, that in general, the way to use macros is to define them using:
#[macro_export]
macro_rules! background(($token:expr) => (($token >> (32 + 8)) & $crate::graphics::mask::Color));
...and then import them into another context that uses them using:
#[macro_use]
extern crate terminal;
...
However, I what I want to do is use the macros from within the crate where they are defined.
If my file structure is:
- lib.rs
- macros.rs
- foo
- foo/mod.rs
- foo/junk.rs
How do I use the macros in macros.rs from junk.rs?
I've tried various combinations of #[macro_use] mod macros
, etc. with no luck. The documentation suggests that if a macro is defined in some scope, then it is available in all child modules... does that mean I have to define my macros in lib.rs?