Skip to content

Commit 37a6c8d

Browse files
committed
doc (book)[01/14]: glossary beef-up
Add a handful of entries to the glossary of The Cargo Book, and add intra-glossary hyperlinks for terms. A full catalog of the specific changes follows. Glossary entries added: + 'Cargo.lock' -- just points to the 'lock file' entry + 'Cargo.toml' -- just points to the 'manifest' entry + 'Module' -- explained in relation to 'crate' + 'Package manager' -- first term in the Introduction + 'Package registry' -- Another term from the Introduction. This entry just points to the 'registry' entry Glossary entries modified: + 'Artifact' - Extend def. to include generated docs. + 'Crate' - Refer to a "Rust crate" as a hint that it is a term that exists outside of Cargo. - Refer to a "Cargo package" (rather than just "package") to reflect the fact that the term is a concept introduced by Cargo (as opposed to being inherent to Rust). - Link to related terms: 'module', 'package', 'registry', and 'target'. + 'Edition' - Link to related term: 'manifest'. + 'Feature' - Link to related term: 'manifest'. + 'Index' - Markdown: add emphasis to first mention of term "index". - Link to related terms: 'crate', 'registry'. + 'Lock file' - Link to related terms: 'package', 'workspace'. + 'Manifest' - Link to related terms: 'package', 'workspace'. + 'Member' - Link to related terms: 'package', 'workspace'. + 'Package' - Note that every target is a crate, and that the type (library or binary) is determined by the Cargo.toml file. - Note relationship to workspaces. - For "package root", add "compare to" note referencing "workspace root". - Link to related terms: 'crate', 'manifest', 'target', 'workspace'. + 'Registry' - Link to related terms: 'crate', 'index', 'package'. + 'Source' - Link to related terms: 'crate', 'package'. + 'Target' - Link to related terms: 'artifact', 'manifest', 'package', 'workspace'. + 'Test Targets' - Link to related terms: 'crate', 'manifest'. + 'Workspace' - For "workspace root", add "compare to" note referencing "package root". - Link to related terms: 'lock file', 'manifest', 'member', 'package'.
1 parent 9051345 commit 37a6c8d

File tree

1 file changed

+117
-41
lines changed

1 file changed

+117
-41
lines changed

src/doc/src/appendix/glossary.md

Lines changed: 117 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,50 @@
33
### Artifact
44

55
An *artifact* is the file or set of files created as a result of the
6-
compilation process. This includes linkable libraries and executable binaries.
6+
compilation process. This includes linkable libraries, executable binaries,
7+
and generated documentation.
8+
9+
### Cargo
10+
11+
*Cargo* is the Rust [*package manager*](#package-manager), and the primary
12+
topic of this book.
13+
14+
### Cargo.lock
15+
16+
See [*lock file*](#lock-file).
17+
18+
### Cargo.toml
19+
20+
See [*manifest*](#manifest).
721

822
### Crate
923

10-
Every target in a package is a *crate*. Crates are either libraries or
11-
executable binaries. It may loosely refer to either the source code of the
12-
target, or the compiled artifact that the target produces. A crate may also
13-
refer to a compressed package fetched from a registry.
24+
A Rust *crate* is either a library or an executable program, referred to as
25+
either a *library crate* or a *binary crate*, respectively.
26+
27+
Every [target](#target) defined for a Cargo [package](#package) is a *crate*.
28+
29+
Loosely, the term *crate* may refer to either the source code of the target or
30+
to the compiled artifact that the target produces. It may also refer to a
31+
compressed package fetched from a [registry](#registry).
32+
33+
The source code for a given crate may be subdivided into [*modules*](#module).
1434

1535
### Edition
1636

1737
A *Rust edition* is a developmental landmark of the Rust language. The
1838
[edition of a package][edition-field] is specified in the `Cargo.toml`
19-
manifest, and individual targets can specify which edition they use. See the
20-
[Edition Guide] for more information.
39+
[manifest](#manifest), and individual targets can specify which edition they
40+
use. See the [Edition Guide] for more information.
2141

2242
### Feature
2343

2444
The meaning of *feature* depends on the context:
2545

2646
- A [*feature*][feature] is a named flag which allows for conditional
2747
compilation. A feature can refer to an optional dependency, or an arbitrary
28-
name defined in a `Cargo.toml` manifest that can be checked within source
29-
code.
48+
name defined in a `Cargo.toml` [manifest](#manifest) that can be checked
49+
within source code.
3050

3151
- Cargo has [*unstable feature flags*][cargo-unstable] which can be used to
3252
enable experimental behavior of Cargo itself.
@@ -40,55 +60,107 @@ The meaning of *feature* depends on the context:
4060

4161
### Index
4262

43-
The index is the searchable list of crates in a registry.
63+
The *index* is the searchable list of [*crates*](#crate) in a
64+
[*registry*](#registry).
4465

4566
### Lock file
4667

4768
The `Cargo.lock` *lock file* is a file that captures the exact version of
48-
every dependency used in a workspace or package. It is automatically generated
49-
by Cargo. See [Cargo.toml vs Cargo.lock].
69+
every dependency used in a [*workspace*](#workspace) or
70+
[*package*](#package). It is automatically generated by Cargo. See
71+
[Cargo.toml vs Cargo.lock].
5072

5173
### Manifest
5274

53-
A [*manifest*][manifest] is a description of a package or a workspace in a
54-
file named `Cargo.toml`.
75+
A [*manifest*][manifest] is a description of a [package](#package) or a
76+
[workspace](#workspace) in a file named `Cargo.toml`.
5577

5678
A [*virtual manifest*][virtual] is a `Cargo.toml` file that only describes a
5779
workspace, and does not include a package.
5880

5981
### Member
6082

61-
A *member* is a package that belongs to a workspace.
83+
A *member* is a [*package*](#package) that belongs to a
84+
[*workspace*](#workspace).
85+
86+
### Module
87+
88+
Rust's module system is used to organize code into logical units called
89+
*modules*, which provide isolated namespaces within the code.
90+
91+
The source code for a given [crate](#crate) may be subdivided into one or more
92+
separate modules. This is usually done to organize the code into areas of
93+
related functionality or to control the visible scope (public/private) of
94+
symbols within the source (structs, functions, and so on).
95+
96+
A [`Cargo.toml`](#manifest) file is primarily concerned with the
97+
[package](#package) it defines, its crates, and the packages of the crates on
98+
which they depend. Nevertheless, you will see the term "module" often when
99+
working with Rust, so you should understand its relationship to a given crate.
62100

63101
### Package
64102

65-
A *package* is a collection of source files and a `Cargo.toml` manifest which
66-
describes the package. A package has a name and version which is used for
67-
specifying dependencies between packages. A package contains multiple targets,
68-
which are either libraries or executable binaries.
103+
A *package* is a collection of source files and a `Cargo.toml`
104+
[*manifest*](#manifest) file which describes the package. A package has a name
105+
and version which is used for specifying dependencies between packages.
106+
107+
A package contains multiple [*targets*](#target), each of which is a
108+
[*crate*](#crate). The `Cargo.toml` file describes the type of the crates
109+
(binary or library) within the package, along with some metadata about each
110+
one -- how each is to be built, what their direct dependencies are, etc., as
111+
described throughout this book.
69112

70113
The *package root* is the directory where the package's `Cargo.toml` manifest
71-
is located.
114+
is located. (Compare with [*workspace root*](#workspace).)
72115

73116
The [*package ID specification*][pkgid-spec], or *SPEC*, is a string used to
74117
uniquely reference a specific version of a package from a specific source.
75118

119+
Small to medium sized Rust projects will only need a single package, though it
120+
is common for them to have multiple crates.
121+
122+
Larger projects may involve multiple packages, in which case Cargo
123+
[*workspaces*](#workspace) can be used to manage common dependencies and other
124+
related metadata between the packages.
125+
126+
### Package manager
127+
128+
Broadly speaking, a *package manager* is a program (or collection of related
129+
programs) in a software ecosystem that automates the process of obtaining,
130+
installing, and upgrading artifacts. Within a programming language ecosystem,
131+
a package manager is a developer-focused tool whose primary functionality is
132+
to download library artifacts and their dependencies from some central
133+
repository; this capability is often combined with the ability to perform
134+
software builds (by invoking the language-specific compiler).
135+
136+
[*Cargo*](#cargo) is the package manager within the Rust ecosystem. Cargo
137+
downloads your Rust [package](#package)’s dependencies
138+
([*artifacts*](#artifact) known as [*crates*](#crate)), compiles your
139+
packages, makes distributable packages, and (optionally) uploads them to
140+
[crates.io][], the Rust community’s [*package registry*](#registry).
141+
142+
### Package registry
143+
144+
See [*registry*](#registry).
145+
76146
### Project
77147

78148
Another name for a [package](#package).
79149

80150
### Registry
81151

82-
A *registry* is a service that contains a collection of downloadable crates
83-
that can be installed or used as dependencies for a package. The default
84-
registry is [crates.io](https://crates.io). The registry has an *index* which
152+
A *registry* is a service that contains a collection of downloadable
153+
[*crates*](#crate) that can be installed or used as dependencies for a
154+
[*package*](#package). The default registry in the Rust ecosystem is
155+
[crates.io](https://crates.io). The registry has an [*index*](#index) which
85156
contains a list of all crates, and tells Cargo how to download the crates that
86157
are needed.
87158

88159
### Source
89160

90-
A *source* is a provider that contains crates that may be included as
91-
dependencies for a package. There are several kinds of sources:
161+
A *source* is a provider that contains [*crates*](#crate) that may be included
162+
as dependencies for a [*package*](#package). There are several kinds of
163+
sources:
92164

93165
- **Registry source** — See [registry](#registry).
94166
- **Local registry source** — A set of crates stored as compressed files on
@@ -110,16 +182,17 @@ See [package ID specification](#package).
110182

111183
The meaning of the term *target* depends on the context:
112184

113-
- **Cargo Target** — Cargo packages consist of *targets* which correspond to
114-
artifacts that will be produced. Packages can have library, binary, example,
115-
test, and benchmark targets. The [list of targets][targets] are configured
116-
in the `Cargo.toml` manifest, often inferred automatically by the [directory
185+
- **Cargo Target** — Cargo [*packages*](#package) consist of *targets* which
186+
correspond to [*artifacts*](#artifact) that will be produced. Packages can
187+
have library, binary, example, test, and benchmark targets. The
188+
[list of targets][targets] are configured in the `Cargo.toml`
189+
[*manifest*](#manifest), often inferred automatically by the [directory
117190
layout] of the source files.
118191
- **Target Directory** — Cargo places all built artifacts and intermediate
119192
files in the *target* directory. By default this is a directory named
120-
`target` at the workspace root, or the package root if not using a
121-
workspace. The directory may be changed with the `--target-dir` command-line
122-
option, the `CARGO_TARGET_DIR` [environment variable], or the
193+
`target` at the [*workspace*](#workspace) root, or the package root if not
194+
using a workspace. The directory may be changed with the `--target-dir`
195+
command-line option, the `CARGO_TARGET_DIR` [environment variable], or the
123196
`build.target-dir` [config option].
124197
- **Target Architecture** — The OS and machine architecture for the built
125198
artifacts are typically referred to as a *target*.
@@ -154,22 +227,24 @@ correctness of code. There are two types of test artifacts:
154227
individual units of code.
155228
* **Integration test target** — An [*integration test
156229
target*][integration-tests] is an executable binary compiled from a *test
157-
target* which is a distinct crate whose source is located in the `tests`
158-
directory or specified by the [`[[test]]` table][targets] in the
159-
`Cargo.toml` manifest. It is intended to only test the public API of a
160-
library, or execute a binary to verify its operation.
230+
target* which is a distinct [*crate*](#crate) whose source is located in the
231+
`tests` directory or specified by the [`[[test]]` table][targets] in the
232+
`Cargo.toml` [*manifest*](#manifest). It is intended to only test the public
233+
API of a library, or execute a binary to verify its operation.
161234

162235
### Workspace
163236

164-
A [*workspace*][workspace] is a collection of one or more packages that share
165-
common dependency resolution (with a shared `Cargo.lock`), output directory,
166-
and various settings such as profiles.
237+
A [*workspace*][workspace] is a collection of one or more
238+
[*packages*](#package) that share common dependency resolution (with a shared
239+
`Cargo.lock` [*lock file*](#lock-file)), output directory, and various
240+
settings such as profiles.
167241

168242
A [*virtual workspace*][virtual] is a workspace where the root `Cargo.toml`
169-
manifest does not define a package, and only lists the workspace members.
243+
[*manifest*](#manifest) does not define a package, and only lists the
244+
workspace [*members*](#member).
170245

171246
The *workspace root* is the directory where the workspace's `Cargo.toml`
172-
manifest is located.
247+
manifest is located. (Compare with [*package root*](#package).)
173248

174249

175250
[Cargo.toml vs Cargo.lock]: ../guide/cargo-toml-vs-cargo-lock.md
@@ -178,6 +253,7 @@ manifest is located.
178253
[Source Replacement]: ../reference/source-replacement.md
179254
[cargo-unstable]: ../reference/unstable.md
180255
[config option]: ../reference/config.md
256+
[crates.io]: https://crates.io/
181257
[directory layout]: ../guide/project-layout.md
182258
[edition guide]: ../../edition-guide/index.html
183259
[edition-field]: ../reference/manifest.md#the-edition-field

0 commit comments

Comments
 (0)