Recall & Review
beginner
What is Cargo in Rust?
Cargo is Rust's package manager and build system. It helps manage dependencies, compile code, and build packages.
Click to reveal answer
beginner
How do you add a new dependency to a Rust project using Cargo?
You add the dependency under the [dependencies] section in the Cargo.toml file with the package name and version.
Click to reveal answer
intermediate
What command updates all dependencies to the latest allowed versions in Cargo?
The command is
cargo update. It updates the Cargo.lock file with the newest versions allowed by Cargo.toml.Click to reveal answer
intermediate
What is the purpose of the Cargo.lock file?
Cargo.lock records the exact versions of dependencies used to ensure reproducible builds across different machines.
Click to reveal answer
advanced
How can you specify a dependency from a Git repository in Cargo.toml?
You specify the dependency with a
git key and the repository URL, for example:<br>mycrate = { git = "https://github.com/owner/repo.git" }Click to reveal answer
Where do you declare dependencies for a Rust project?
✗ Incorrect
Dependencies are declared in Cargo.toml under the [dependencies] section.
What does the command
cargo build do?✗ Incorrect
cargo build compiles your Rust project and fetches any missing dependencies.What file ensures that all developers use the same dependency versions?
✗ Incorrect
Cargo.lock locks the exact versions of dependencies to ensure consistent builds.
How do you specify a dependency version range in Cargo.toml?
✗ Incorrect
"^1.2.3" means Cargo can use versions compatible with 1.2.3, like 1.3.0 but not 2.0.0.
Which command updates the Cargo.lock file to the latest allowed dependency versions?
✗ Incorrect
cargo update updates dependencies in Cargo.lock to the newest versions allowed by Cargo.toml.Explain how Cargo manages dependencies in a Rust project.
Think about where dependencies are listed and how Cargo ensures consistent builds.
You got /5 concepts.
Describe how to add a dependency from a Git repository using Cargo.
Focus on the syntax inside Cargo.toml for git dependencies.
You got /4 concepts.