Rust Crate Architecture Quiz

Rust
0 Passed
0% acceptance

Master the design and organization of Rust crates including module systems, workspace management, dependency handling, and publishing strategies

40 Questions
~80 minutes
1

Question 1

What is a crate in Rust?

A
A compilation unit - either a library or executable
B
A package manager
C
A module
D
A file
2

Question 2

What is the difference between a package and a crate?

A
Package is Cargo.toml + source, crate is compilation unit
B
They are identical
C
Package is smaller
D
No difference
3

Question 3

What is the module system in Rust?

A
Hierarchical organization using mod, pub, use keywords
B
File system only
C
No module system
D
Module system doesn't exist
4

Question 4

What does pub(crate) mean?

A
Visible within the current crate but not externally
B
Public everywhere
C
Private
D
pub(crate) doesn't exist
5

Question 5

What is the crate root?

A
src/lib.rs for libraries, src/main.rs for binaries
B
Cargo.toml
C
src/mod.rs
D
No crate root
6

Question 6

How do you declare a module?

A
mod module_name; or mod module_name { ... }
B
module module_name;
C
use module_name;
D
No module declaration
7

Question 7

What is the use keyword for?

A
Bringing items into scope, creating aliases
B
Declaring modules
C
Making items public
D
use doesn't exist
8

Question 8

What is a prelude?

A
Common items automatically imported, like std::prelude::*
B
Module introduction
C
Package prelude
D
Prelude doesn't exist
9

Question 9

What is a workspace in Cargo?

A
Multiple packages developed together in one repository
B
Single package
C
Cargo configuration
D
Workspace doesn't exist
10

Question 10

What is path dependency?

A
Depending on local crates during development
B
File system paths
C
Dependency paths
D
Path dependency doesn't exist
11

Question 11

What are feature flags?

A
Optional functionality enabled with --features
B
Compilation flags
C
Cargo flags
D
Feature flags don't exist
12

Question 12

What is semantic versioning (semver)?

A
MAJOR.MINOR.PATCH version scheme with compatibility rules
B
Random versioning
C
Date-based versioning
D
Semver doesn't exist
13

Question 13

What is Cargo.lock for?

A
Locks dependency versions for reproducible builds
B
Locks Cargo
C
Configuration lock
D
Cargo.lock doesn't exist
14

Question 14

What is crates.io?

A
Official Rust package registry
B
Code editor
C
Build tool
D
crates.io doesn't exist
15

Question 15

What is the difference between library and binary crates?

A
Libraries provide functionality, binaries are executables
B
They are identical
C
Libraries are smaller
D
No difference
16

Question 16

What is crate visibility?

A
pub = public, pub(crate) = crate-visible, private = module-only
B
All public
C
All private
D
Visibility doesn't exist
17

Question 17

What is re-exporting?

A
pub use item; to make internal items public in crate API
B
Exporting again
C
Re-importing
D
Re-exporting doesn't exist
18

Question 18

What is the glob operator in use?

A
use module::*; imports all public items
B
Wildcard import
C
Glob pattern
D
Glob doesn't exist
19

Question 19

What is a facade pattern in crate design?

A
Single entry point re-exporting functionality from submodules
B
Design pattern
C
Architecture pattern
D
Facade doesn't exist
20

Question 20

What is version pinning?

A
Using exact versions (=1.2.3) to prevent updates
B
Version control
C
Version locking
D
Version pinning doesn't exist
21

Question 21

What is a dev-dependency?

A
Dependencies only needed for development/testing
B
Development tools
C
Build dependencies
D
Dev-dependency doesn't exist
22

Question 22

What is conditional compilation?

A
#[cfg(...)] attributes control when code is compiled
B
Runtime conditions
C
Build conditions
D
Conditional compilation doesn't exist
23

Question 23

What is target-specific dependencies?

A
Dependencies only compiled for specific platforms
B
Target dependencies
C
Platform dependencies
D
Target-specific doesn't exist
24

Question 24

What is a build script?

A
build.rs file that runs before compilation
B
Build tool
C
Compilation script
D
Build script doesn't exist
25

Question 25

What is the package registry alternative?

A
Private registries or git dependencies for internal crates
B
Alternative registries
C
Package alternatives
D
No alternatives
26

Question 26

What is crate documentation?

A
/// comments processed by rustdoc into HTML docs
B
Code comments
C
Manual docs
D
Crate documentation doesn't exist
27

Question 27

What is API stability?

A
Commitment to not breaking changes in public API
B
Code stability
C
Version stability
D
API stability doesn't exist
28

Question 28

What is a workspace member?

A
Package listed in workspace.members array
B
Workspace component
C
Team member
D
Workspace member doesn't exist
29

Question 29

What is the package ID?

A
name + version + source uniquely identifying a package
B
Package name
C
Package version
D
Package ID doesn't exist
30

Question 30

What is a virtual manifest?

A
Cargo.toml with [workspace] but no [package] section
B
Virtual package
C
Manifest file
D
Virtual manifest doesn't exist
31

Question 31

What is dependency resolution?

A
Finding compatible versions of all dependencies
B
Solving dependencies
C
Dependency solving
D
Dependency resolution doesn't exist
32

Question 32

What is a cyclic dependency?

A
When crate A depends on B which depends on A
B
Circular dependency
C
Dependency cycle
D
Cyclic dependency doesn't exist
33

Question 33

What is a meta-package?

A
Package that only re-exports other crates, no code
B
Meta package
C
Package wrapper
D
Meta-package doesn't exist
34

Question 34

What is the replace directive?

A
Override dependency with local version for development
B
Replace dependencies
C
Dependency replacement
D
Replace doesn't exist
35

Question 35

What is patch directive?

A
Apply local changes to dependencies without forking
B
Patch dependencies
C
Dependency patching
D
Patch doesn't exist
36

Question 36

What is a binary target?

A
Executable defined in [[bin]] section or src/main.rs
B
Binary file
C
Target binary
D
Binary target doesn't exist
37

Question 37

What is an example target?

A
Executable example in examples/ directory
B
Code example
C
Example file
D
Example target doesn't exist
38

Question 38

What is a benchmark target?

A
Performance test using #[bench] (unstable) or external crates
B
Benchmark file
C
Performance test
D
Benchmark target doesn't exist
39

Question 39

What is the default binary?

A
src/main.rs or binary specified as default-run in Cargo.toml
B
Main binary
C
Default executable
D
Default binary doesn't exist
40

Question 40

In a large-scale Rust project with multiple teams, complex dependencies, and both libraries and applications, what crate architecture principles would you follow?

A
Clear boundaries with workspaces, semantic versioning, comprehensive testing, stable APIs, proper documentation, feature flags for optional functionality
B
Single monolithic crate
C
No architecture needed
D
Random organization

QUIZZES IN Rust