jevsnes.git / third-party / rust / top / README.md
1# Chapter 21: top, an empty file with a job
2
3This is the shortest chapter, about the shortest file in the repository.
4`lib.rs` in here is empty, and it has to exist.
5
6Chapter 19's `Cargo.toml` is a list of dependencies, but cargo and reindeer
7only accept a list of dependencies if it belongs to a *package*, and a
8package must have something to build. So the manifest declares one:
9
10```toml
11[package]
12name = "rust-third-party"
13
14[lib]
15path = "top/lib.rs"
16```
17
18and this is that something. Nothing compiles it into anything that runs,
19and nothing depends on it. It is a doorstop: the door is the whole
20third-party graph, and it stays open because this is wedged under it.
21
22> **Aside.** The same trick turns up wherever Rust is built by something
23> other than cargo: a stand-in top-level crate whose only purpose is to
24> hold the dependency list. reindeer's own examples name theirs `top` too.
25
26> **Try it.** `wc -c third-party/rust/top/lib.rs` prints `0`, and
27> `grep -n top third-party/rust/Cargo.toml` shows the one line that needs it.
28
29## For the people who maintain it
30
31### In this folder
32
33| Path | What |
34| --- | --- |
35| [lib.rs](lib.rs) | Empty, on purpose. |
36| [README.md](README.md) | This chapter. |
37| [CLAUDE.md](CLAUDE.md) | Leave it alone, for agents. |
38
39← Previous: [Chapter 20, fixups/](../fixups/) · Up: [rust](../) · Next: [Chapter 22, research/](../../../research/) →