Recall & Review
beginner
What is a crate in Rust?
A crate is a package of Rust code. It can be a library or a binary. Crates help organize and share code.
Click to reveal answer
beginner
How do you add an external crate to your Rust project?
You add the crate name and version to the
[dependencies] section in the Cargo.toml file.Click to reveal answer
beginner
What command downloads and compiles external crates listed in
Cargo.toml?The command
cargo build downloads and compiles all dependencies including external crates.Click to reveal answer
beginner
How do you use an external crate in your Rust code after adding it to
Cargo.toml?You add
use crate_name::module; at the top of your Rust file to bring the crate's code into scope.Click to reveal answer
intermediate
What is the purpose of
extern crate in Rust?In modern Rust editions,
extern crate is mostly optional. It was used to link external crates before the 2018 edition.Click to reveal answer
Where do you specify external crates for a Rust project?
✗ Incorrect
External crates are listed in the Cargo.toml file under the [dependencies] section.
Which command downloads and compiles external crates?
✗ Incorrect
cargo build downloads and compiles all dependencies including external crates.How do you bring an external crate into scope in your Rust code?
✗ Incorrect
You use the
use keyword to bring external crate modules into scope.Is
extern crate still required in Rust 2021 edition?✗ Incorrect
extern crate is mostly optional in Rust 2018 and later editions.What file manages dependencies in a Rust project?
✗ Incorrect
Cargo.toml is the configuration file where dependencies are declared.
Explain the steps to add and use an external crate in a Rust project.
Think about where you declare, how you get it, and how you use it.
You got /3 concepts.
What is the role of Cargo in managing external crates?
Cargo is like the project helper for Rust.
You got /4 concepts.