Packages, Crates, Modules Flashcards
How many binary crates can a package contain?
Multiple.
How many library crates can a package contain?
One.
What is the module system in Rust?
A collection of features that help organize code. Features such as which code details are public or private, and what names in a program are in what scope.
What Rust features make up the module system?
Packages, Crates, Modules and Use, Paths.
What are packages in Cargo?
A Cargo feature that lets you build, test, and share crates. One or more crates that provide a set of functionality
What are crates in Cargo?
A tree of modules that produces a library or executable.
What do Modules do?
Organize code within a crate into groups for readability and easy reuse. Modules also control the privacy of items.
What are Paths?
A way of naming an item, such as a struct, function, or module.
What is the Crate root file?
Source file that the Rust compiler starts from and makes up the root module of your crate.
What file does every Package contain?
Cargo.toml
What does a Cargo.toml file describe?
How to build the Crates in a package.
What must a Package contain?
Zero or one Library crates.
What is the command to create a Package?
cargo new
What convention does Cargo follow regarding src/main.rs?
src/main.rs is the crate root of a binary crate with the same name as the package.
What convention does Cargo follow regarding src/lib.rs?
If the package directory contains src/lib.rs then src/lib.rs is the crate root of a Library crate with the same name as the package.