I have question about use statement with macros. Let me start by explaining my code.
I created a macro into its own file, macro.rs:
use dates::now_date_time_str;
// the above line creates a warning:
// warning: unused import: `dates::now_date_time_str`
macro_rules! debugln {
($exp : expr) =>
{
let local = now_date_time_str();
println!("{} -> {}", local, $exp);
};
() =>
{
println!("");
};
}
The macro makes use of function defined in dates.rs. I haven't included that code here, thinking its not relevant but I can add it if needed.
I then consumed this macro in main.rs like this:
extern crate chrono;
mod dates;
#[macro_use]
mod macros;
use dates::now_date_time_str;
// if I dont include the above, I get the following error!!!
// error[E0425]: cannot find function `now_date_time_str` in this scope
fn main() {
debugln!("start of app");
}
I understand macros are expanded inline. What I do not understand is why the use statement in macro.rs is "unused" and not applied with "macro" mod is included in main.rs.
It seems a little cumbersome to create macros if the consumer has to know which uses statements to include in its code. Am I doing something wrong that makes macros so hard to include?
Thnx
Matt