【发布时间】:2017-07-11 11:50:45
【问题描述】:
我使用以下文件结构:
├── 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 文件中使用我的doc! 宏?我还尝试将#[macro_use] 添加到mod models; 之类的内容中,但没有任何效果。
【问题讨论】:
-
你说
!doc,但是宏写成doc!。如果这不是问题,那么您没有提供任何接近足够的信息。我们需要查看编译失败的代码,以及编译器的输出。 -
@DK 抱歉。但是我写了文档!在我的代码中
标签: rust rust-cargo