rCore_Tutorial_CP2
这一章的文件结构略微的复杂了一点,需要开始之前先稍微强化一下对rust mod use等关键字的认知。。。
rust mod/use/extern
Packages and Crates rust认为src下的main.rs是二进制crate的主文件,而lib.rs则是库crate的主文件,所以这里的lib.rs是主文件,和cargo.toml中的name赋值为user_lib
并无关联。。。
When we entered the command, Cargo created a Cargo.toml file, giving us a package. Looking at the contents of Cargo.toml, there’s no mention of src/main.rs because Cargo follows a convention that src/main.rs is the crate root of a binary crate with the same name as the package. Likewise, Cargo knows that if the package directory contains src/lib.rs, the package contains a library crate with the same name as the package, and src/lib.rs is its crate root. Cargo passes the crate root files to rustc to build the library or binary.