summaryrefslogtreecommitdiffstats
path: root/src/doc/book/redirects/crates-and-modules.md
blob: d526c956414777624335596e15d7a363dbd30e58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
% Crates and Modules

<small>There is a new edition of the book and this is an old link.</small>

> 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.

```rust
mod network {
    fn connect() {
    }
}
```

---

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

* **[in the current edition: Ch 7.01 — `mod` and the Filesystem][2]**
* [in the current edition: Ch 14.02 — Publishing a Crate to Crates.io][3]
* <small>[In the first edition: Ch 3.25 — Crates and Modules][1]</small>


[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/crates-and-modules.html
[2]: ch07-00-managing-growing-projects-with-packages-crates-and-modules.html
[3]: ch14-02-publishing-to-crates-io.html