-
Book Overview & Buying
-
Table Of Contents
The Rust Programming Handbook
By :
To get a good grasp on organizing a project, let’s start by looking at the physical artifacts Cargo creates.
When you run ‘cargo new', you’re creating a Package, basically, a directory with a Cargo.toml file that explains how to build your code. Think of it as the main container for everything. Inside this package, your actual code lives in Crates.
What is a crate? A crate is just the smallest piece of code that the Rust compiler works on at a time. Usually, you’ll be dealing with binary crates (which turn into a program you can run) or library crates (which hold code shared across projects). A package can have many binaries, but it will only have one library.
A Package essentially functions as a project bundle. When you run ‘cargo new my_project' in your terminal, you’re creating a package. The key element of a package is the Cargo...