0Pricing
Learn Rust Coding · Lesson

Crates and the Crate Root

Project structure.

What Is a Crate?

A crate is the smallest unit the Rust compiler works with. There are two kinds: a binary crate that compiles to an executable, and a library crate that other code depends on.

Binary vs Library

A binary crate has a main function and produces a program you can run. A library crate has no main; it exposes reusable items for other crates.

  • Binary root: src/main.rs
  • Library root: src/lib.rs

All lessons in this course

  1. Modules and mod
  2. pub and Visibility
  3. use and Paths
  4. Crates and the Crate Root
← Back to Learn Rust Coding