Real Projects · 16 min · free with an account

Dependencies

Lesson preview · about 30%

A dependency is a version requirement, not a fixed version.

Core idea

"1.2" means >=1.2.0 and <2.0.0; the lockfile records what was actually chosen.

Start with the idea

"1.2" means any 1.x at or above 1.2, because Cargo follows SemVer: patch and minor releases must stay compatible. The resolver picks the highest match and records the exact choice in Cargo.lock, and features let one crate ship optional pieces you opt into rather than paying for by default.

A dependency declaration is a compatibility request, not a permanent pin. In Cargo's default caret requirement, version = "1.2" accepts compatible 1.x releases from 1.2 upward but not 2.0. Cargo.lock records the concrete versions selected for a particular resolution, so two developers can rebuild the same application graph. Read both files when investigating why a new release did or did not appear in your build.

Features let a dependency expose optional capabilities.

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