Rust logo
Rust 1.65.0-dev

Crates and Modules

There is a new edition of the book and this is an old link.

Rust has a module system that enables the reuse of code in an organized fashion. A module is a namespace that contains definitions of functions or types, and you can choose whether those definitions are visible outside their module (public) or not (private).

A crate is a project that other people can pull into their projects as a dependency.

mod network {
    fn connect() {
    }
}
Run

Here are the relevant sections in the new and old books: