1
我用下面的文件结构:不能在子子模块范围内使用`DOC`宏从MongoDB的箱子
├── src
│ ├── main.rs // Macros from here
│ ├── models
│ │ ├── mod.rs // Loads the user.rs file
│ │ └── user.rs // Should be visible here
├── Cargo.toml
我main.rs
文件导入的东西,如:
#[macro_use]
extern crate mongodb;
mod models;
我user.rs
文件看起来像:
pub struct User {
username: String,
password: String,
}
impl User {
fn create_doc() {
// Some code, but doc! from crate mongodb is not in this scope.
}
}
我如何使用我的在user.rs
文件中有210个宏?我也尝试添加#[macro_use]
到像mod models;
这样的东西,但没有任何工作。
你说'!doc',但是宏被写为'doc!'。如果这不是问题,那么你没有提供足够的信息。我们需要查看无法编译的代码以及编译器的输出。 –
@DK对不起。但我写了doc!在我的代码 –