Rust 锈病包括mod

Rust 锈病包括mod,rust,Rust,我有这样的等级制度: src/main.rs mod animals; mod race fn main() { let s = animals::Animal(12.0, 1.8, 24, animals::race::white); println!("Hello, world!"); } src/animals/animal.rs mod race; pub mod animal { pub struct Animal { height: f64, weight: f

我有这样的等级制度: src/main.rs

mod animals;
mod race
fn main() {
  let s = animals::Animal(12.0, 1.8, 24, animals::race::white);
  println!("Hello, world!");
}
src/animals/animal.rs

mod race;
pub mod animal {
  pub struct Animal {
  height: f64,
  weight: f64,
  age: u32,
  raceT: race
  }
}
src/动物/种族

pub mod race{
  pub enum Race {
      whit,
      black,
      yellow
  }
}
a有一个阿罗尔:

--> src\main.rs:1:5
  |
1 | mod animals;
  |     ^^^^^^^
  |
 = help: name the file either animals.rs or animals\mod.rs inside the  directory "src"

 error: aborting due to previous error

如何正确添加模块以避免出现错误

animals.rs
重命名为
mod.rs
。您可以找到有关跨文件拆分模块的详细信息。

“将文件命名为animates.rs或animates\mod.rs”--换句话说,将您的animates.rs移动到顶级src目录,或将其重命名为animates/-目录中的mod.rs