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
- Modules and mod
- pub and Visibility
- use and Paths
- Crates and the Crate Root