Cargo Workflow · 16 min · free with an account

Dependency Kinds

Lesson preview · about 30%

Separate runtime, build, and test-only tools.

Core idea

Normal dependencies become part of a target graph, build dependencies support build scripts, and dev dependencies exist for tests and examples.

Start with the idea

Normal dependencies become part of a target graph, build dependencies support build scripts, and dev dependencies exist for tests and examples. The distinction keeps production graphs smaller and clearer.

Cargo separates dependencies by the role they play in a package. Normal [dependencies] are needed to build the library or binary target. [build-dependencies] are available to a build.rs script that runs during the build, often to generate files or detect native libraries. [dev-dependencies] support tests, examples, and benchmarks but are not ordinary runtime dependencies of the published library. The distinction helps make a package's requirements understandable.

Read the sample manifest and ask where each crate is used.

Keep learning, for free

The rest of this lesson is waiting for you.

Create a free account to read the complete explanation, see the infographic, explore the code, and try the exercises. All 742 lessons and algorithm steps are included.

No payment details. Your account opens the complete Academy.

← All lessons in Cargo & Real Projects