In Rust, what is the purpose of a mod.rs file?
在我见过的某些Rust项目中(即pczarn / rustboot),无论出于何种原因,我都在目录中见过
mod.rs文件的用途是什么,何时使用?
想象一下以下目录结构:
1 2 3 4 | code/ `- main.rs - something/ `- mod.rs |
如果在
替代方法是在
回顾一下,当您编写一个空模块声明(例如
-
同一目录中名为
something.rs 的文件 -
同一目录中名为
something 的文件夹中名为mod.rs 的文件
然后,它将使用这些文件中的任何一个的内容作为模块声明的内容。