Rust provides a robust ecosystem for package management and distribution through crates. This set of 30 multiple-choice questions covers important topics such as organizing and structuring crates, managing dependencies in Cargo.toml, writing documentation, and publishing crates to crates.io. These practices help developers create well-structured libraries and applications in Rust.
Cargo.tomlRust.tomlmanifest.tomlcrate.tomlsrc directorybin directorylib directorydoc directorymain.rslib.rsindex.rsstart.rssrc/lib.rssrc/main.rslib.rs/srcbin/lib.rslib.rs file in a Rust crate?
Cargo.toml fileCargo.tomlmain.rsmanifest.rscrate.jsonCargo.tomluse keywordCargo.toml file in a multi-crate project?
src directorylib directorybin directoryCargo.toml configurationfiles.toml.rs files in the project directory//////* */--cargo buildcargo testcargo doccargo publish#[link]/// with the crate URLCargo.tomluse/// followed by example code blockscargo examplesrc folderdoc attributes in Rust?#[doc] attribute with a URLuse keyword for external linksCargo.toml filecargo doc --open command do?Cargo.toml file?[dependencies] sectionsrc directorydependencies.rs fileCargo.lock fileCargo.toml?name = "1.0.0"name = [1.0.0]name = 1.0.0name = { version = "1.0.0" }Cargo.toml file?cargo installcargo buildcargo updatecargo fetchCargo.lock file?cargo updatecargo upgradecargo installcargo build[dev-dependencies] section in Cargo.toml?Cargo.toml?[optional] section[dependencies] section with optional = trueCargo.toml?path attributelocal attribute[local-dependencies] sectionsrc directoryCargo.toml?[features] section to define optional functionality[dev-features] sectionCargo.lock filecargo checkcargo verifycargo updatecargo audit| Qno | Answer |
|---|---|
| 1 | C) Crate |
| 2 | A) Cargo.toml |
| 3 | A) Inside the src directory |
| 4 | A) main.rs |
| 5 | A) src/lib.rs |
| 6 | B) It contains the library code for the crate |
| 7 | A) Cargo.toml |
| 8 | A) Through the use of dependencies specified in Cargo.toml |
| 9 | A) Root of the project |
| 10 | A) Based on the Cargo.toml configuration |
| 11 | A) /// |
| 12 | A) Just before the function signature |
| 13 | C) cargo doc |
| 14 | C) By adding a dependency in Cargo.toml |
| 15 | B) A summary of what the function or crate does |
| 16 | A) By using /// followed by example code blocks |
| 17 | C) To generate HTML documentation from comments |
| 18 | A) Markdown |
| 19 | A) By using the #[doc] attribute with a URL |
| 20 | A) It opens the crate documentation in a web browser |
| 21 | A) Under the [dependencies] section |
| 22 | D) name = { version = "1.0.0" } |
| 23 | B) cargo build |
| 24 | A) To lock the dependencies to specific versions |
| 25 | A) cargo update |
| 26 | A) To specify dependencies used only for testing and development |
| 27 | B) Yes, by using the [dependencies] section with optional = true |
| 28 | A) By using the path attribute |
| 29 | A) Using the [features] section to define optional functionality |
| 30 | C) cargo update |