我有这个板条箱/src/lib.rs
,我试图在其中运行测试:
#![crate_type = "lib"]
#![crate_name = "mycrate"]
pub mod mycrate {
pub struct Struct {
field: i32,
}
impl Struct {
pub fn new(n: i32) -> Struct {
Struct { field: n }
}
}
}
测试文件位于/tests/test.rs
:
extern crate mycrate;
use mycrate::*;
#[test]
fn test() {
...
}
运行cargo test
给出了这个错误:
tests/test.rs:3:5: 3:16 error: import `mycrate` conflicts with imported crate in this module (maybe you meant `use mycrate::*`?) [E0254]
tests/test.rs:3 use mycrate::*;
^~~~~~~~~
我在这里做错了什么?