我有一个定义使用正则表达式板条箱的宏的文件。是否有机会避免使用我的宏将
use regex::Regex;
放入所有文件中?
我能想到两种可能性:
macro_rules! foo {
() => {
let x: ::regex::Regex;
}
}
macro_rules! foo {
() => {{ // NB: double `{` to create a scope
use ::regex::Regex;
let x: Regex;
}}
}