我的板条箱的结构如下:
pub mod components {
pub mod ch {
pub struct CH {
// struct definition
}
impl CH {
pub fn new() -> CH {
CH {}
}
}
}
}
use components::ch::CH;
#[cfg(test)]
mod tests {
#[test]
fn ch_test() {
let test_ch = CH::new();
}
}
运行测试时,出现错误:
error[E0433]: failed to resolve: use of undeclared type or module `CH`
--> src/lib.rs:22:23
|
22 | let test_ch = CH::new();
| ^^ use of undeclared type or module `CH`
我还会收到一条警告,指出我的导入尚未使用:
warning: unused import: `components::ch::CH`
--> src/lib.rs:15:5
|
15 | use components::ch::CH;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
这告诉我模块结构无法正确识别我的代码。我检查了Rust by Example,但看不到代码有什么不同。我的文件结构在哪里连接不正确?