@@ -81,7 +81,7 @@ repository by mistake.
8181publish = false
8282```
8383
84- ## Package metadata
84+ ## Package Metadata
8585
8686There are a number of optional metadata fields also accepted under the
8787` [package] ` section:
@@ -91,15 +91,15 @@ There are a number of optional metadata fields also accepted under the
9191# ...
9292
9393# A short blurb about the package. This is not rendered in any format when
94- # uploaded to crates.io (aka this is not markdown)
94+ # uploaded to crates.io (aka this is not markdown).
9595description = " ..."
9696
97- # These URLs point to more information about the repository
97+ # These URLs point to more information about the repository.
9898documentation = " ..."
9999homepage = " ..."
100100repository = " ..."
101101
102- # This points to a file in the repository (relative to this Cargo.toml). The
102+ # This points to a file in the repository (relative to this ` Cargo.toml` ). The
103103# contents of this file are stored and indexed in the registry.
104104readme = " ..."
105105
@@ -110,12 +110,12 @@ keywords = ["...", "..."]
110110# This is a string description of the license for this package. Currently
111111# crates.io will validate the license provided against a whitelist of known
112112# license identifiers from http://spdx.org/licenses/. Multiple licenses can be
113- # separated with a `/`
113+ # separated with a `/`.
114114license = " ..."
115115
116116# If a project is using a nonstandard license, then this key may be specified in
117117# lieu of the above key and must point to a file relative to this manifest
118- # (similar to the readme key)
118+ # (similar to the readme key).
119119license-file = " ..."
120120```
121121
@@ -142,13 +142,13 @@ geometry = { path = "crates/geometry" }
142142
143143You can specify the source of a dependency in a few ways:
144144
145- * ` git = "<git-url>" ` : A git repository with a ` Cargo.toml ` inside it (not
146- necessarily at the root). The ` rev ` , ` tag ` , and ` branch ` options are also
145+ * ` git = "<git-url>" ` refers to a git repository with a ` Cargo.toml ` inside it
146+ (not necessarily at the root). The ` rev ` , ` tag ` , and ` branch ` options are also
147147 recognized to use something other than the ` master ` branch.
148- * ` path = "<relative-path>" ` : A path relative to the current ` Cargo.toml `
149- pointing to another directory with a ` Cargo.toml ` and an associated package .
150- * If ` path ` and ` git ` are omitted, then a dependencies will come from crates.io
151- and use the ` version ` key to indicate the version requirement.
148+ * ` path = "<relative-path>" ` refers to another directory with a ` Cargo.toml `
149+ inside it. The specified path should be relative to the current ` Cargo.toml ` .
150+ * If ` path ` and ` git ` are omitted, the dependency will come from crates.io, and
151+ the ` version ` key will be used to indicate the version requirement.
152152
153153Dependencies from crates.io can also use a shorthand where just the version
154154requirement is specified:
@@ -213,8 +213,8 @@ native = { path = "native/x86_64" }
213213
214214# The ` [profile.*] ` Sections
215215
216- Cargo supports custom configuration of how rustc is invoked through ** profiles**
217- at the top level. Any manifest may declare a profile, but only the ** top level**
216+ Cargo supports custom configuration of how rustc is invoked through profiles at
217+ the top level. Any manifest may declare a profile, but only the top level
218218project’s profiles are actually read. All dependencies’ profiles will be
219219overridden. This is done so the top-level project has control over how its
220220dependencies are compiled.
@@ -224,17 +224,17 @@ configuration available to them. Listed below is the configuration available,
224224along with the defaults for each profile.
225225
226226``` toml
227- # The development profile, used for `cargo build`
227+ # The development profile, used for `cargo build`.
228228[profile .dev ]
229- opt-level = 0 # Controls the --opt-level the compiler builds with
230- debug = true # Controls whether the compiler passes `-g`
231- rpath = false # Controls whether the compiler passes `-C rpath`
232- lto = false # Controls `-C lto` for binaries and staticlibs
233- debug-assertions = true # Controls whether debug assertions are enabled
234- codegen-units = 1 # Controls whether the compiler passes `-C codegen-units`
235- # `codegen-units` is ignored when `lto = true`
236-
237- # The release profile, used for `cargo build --release`
229+ opt-level = 0 # controls the ` --opt-level` the compiler builds with
230+ debug = true # controls whether the compiler passes `-g`
231+ rpath = false # controls whether the compiler passes `-C rpath`
232+ lto = false # controls `-C lto` for binaries and staticlibs
233+ debug-assertions = true # controls whether debug assertions are enabled
234+ codegen-units = 1 # controls whether the compiler passes `-C codegen-units`
235+ # `codegen-units` is ignored when `lto = true`
236+
237+ # The release profile, used for `cargo build --release`.
238238[profile .release ]
239239opt-level = 3
240240debug = false
@@ -243,7 +243,7 @@ lto = false
243243debug-assertions = false
244244codegen-units = 1
245245
246- # The testing profile, used for `cargo test`
246+ # The testing profile, used for `cargo test`.
247247[profile .test ]
248248opt-level = 0
249249debug = true
@@ -252,7 +252,7 @@ lto = false
252252debug-assertions = true
253253codegen-units = 1
254254
255- # The benchmarking profile, used for `cargo bench`
255+ # The benchmarking profile, used for `cargo bench`.
256256[profile .bench ]
257257opt-level = 3
258258debug = false
@@ -261,7 +261,7 @@ lto = false
261261debug-assertions = false
262262codegen-units = 1
263263
264- # The documentation profile, used for `cargo doc`
264+ # The documentation profile, used for `cargo doc`.
265265[profile .doc ]
266266opt-level = 0
267267debug = true
@@ -273,13 +273,13 @@ codegen-units = 1
273273
274274# The ` [features] ` Section
275275
276- Cargo supports ** features** to allow expression of:
276+ Cargo supports features to allow expression of:
277277
278- * Conditional compilation options (usable through ` cfg ` attributes);
279- * Optional dependencies, which enhance a package, but are not required;
280- * Clusters of optional dependencies, such as “ postgres” , that would include the
278+ * conditional compilation options (usable through ` cfg ` attributes);
279+ * optional dependencies, which enhance a package, but are not required; and
280+ * clusters of optional dependencies, such as ` postgres ` , that would include the
281281 ` postgres ` package, the ` postgres-macros ` package, and possibly other packages
282- (such as development-time mocking libraries, debugging tools, etc.)
282+ (such as development-time mocking libraries, debugging tools, etc.).
283283
284284A feature of a package is either an optional dependency, or a set of other
285285features. The format for specifying features is:
@@ -289,7 +289,7 @@ features. The format for specifying features is:
289289name = " awesome"
290290
291291[features ]
292- # The “ default” set of optional packages. Most people will want to use these
292+ # The default set of optional packages. Most people will want to use these
293293# packages, but they are strictly optional. Note that `session` is not a package
294294# but rather another feature listed in this manifest.
295295default = [" jquery" , " uglifier" , " session" ]
@@ -298,7 +298,7 @@ default = ["jquery", "uglifier", "session"]
298298# like `#[cfg(feature = "go-faster")]`.
299299go-faster = []
300300
301- # The “ secure-password” feature depends on the bcrypt package. This aliasing
301+ # The ` secure-password` feature depends on the bcrypt package. This aliasing
302302# will allow people to talk about the feature in a higher-level way and allow
303303# this package to add more requirements to the feature in the future.
304304secure-password = [" bcrypt" ]
@@ -309,13 +309,13 @@ secure-password = ["bcrypt"]
309309session = [" cookie/session" ]
310310
311311[dependencies ]
312- # These packages are mandatory and form the core of this package’s distribution
312+ # These packages are mandatory and form the core of this package’s distribution.
313313cookie = " 1.2.0"
314314oauth = " 1.1.0"
315315route-recognizer = " =2.1.0"
316316
317317# A list of all of the optional dependencies, some of which are included in the
318- # above “ features” . They can be opted into by apps.
318+ # above ` features` . They can be opted into by apps.
319319jquery = { version = " 1.0.2" , optional = true }
320320uglifier = { version = " 1.5.3" , optional = true }
321321bcrypt = { version = " *" , optional = true }
@@ -338,23 +338,23 @@ The usage of features is subject to a few rules:
338338
3393391 . Feature names must not conflict with other package names in the manifest.
340340 This is because they are opted into via ` features = [...] ` , which only has a
341- single namespace
341+ single namespace.
3423422 . With the exception of the ` default ` feature, all features are opt-in. To opt
343343 out of the default feature, use ` default-features = false ` and cherry-pick
344344 individual features.
3453453 . Feature groups are not allowed to cyclically depend on one another.
346- 4 . Dev-dependencies cannot be optional
347- 5 . Features groups can only reference optional dependencies
346+ 4 . Dev-dependencies cannot be optional.
347+ 5 . Features groups can only reference optional dependencies.
3483486 . When a feature is selected, Cargo will call ` rustc ` with `--cfg
349349 feature="${feature_name}"`. If a feature group is included, it and all of its
350350 individual features will be included. This can be tested in code via
351- ` #[cfg(feature = "foo")] `
351+ ` #[cfg(feature = "foo")] ` .
352352
353353Note that it is explicitly allowed for features to not actually activate any
354354optional dependencies. This allows packages to internally enable/disable
355355features without requiring a new dependency.
356356
357- ## Usage In End Products
357+ ## Usage in End Products
358358
359359One major use-case for this feature is specifying optional features in
360360end-products. For example, the Servo project may want to include optional
@@ -369,28 +369,28 @@ $ cargo build --release --features "shumway pdf"
369369
370370Default features could be excluded using ` --no-default-features ` .
371371
372- ## Usage In Packages
372+ ## Usage in Packages
373373
374- In most cases, the concept of “ optional dependency” in a library is best
374+ In most cases, the concept of * optional dependency* in a library is best
375375expressed as a separate package that the top-level application depends on.
376376
377377However, high-level packages, like Iron or Piston, may want the ability to
378378curate a number of packages for easy installation. The current Cargo system
379379allows them to curate a number of mandatory dependencies into a single package
380380for easy installation.
381381
382- In some cases, packages may want to provide additional curation for ** optional**
382+ In some cases, packages may want to provide additional curation for optional
383383dependencies:
384384
385- * Grouping a number of low-level optional dependencies together into a single
386- high-level “ feature”.
387- * Specifying packages that are recommended (or suggested) to be included by
388- users of the package.
389- * Including a feature (like ` secure-password ` in the motivating example) that
385+ * grouping a number of low-level optional dependencies together into a single
386+ high-level feature;
387+ * specifying packages that are recommended (or suggested) to be included by
388+ users of the package; and
389+ * including a feature (like ` secure-password ` in the motivating example) that
390390 will only work if an optional dependency is available, and would be difficult
391- to implement as a separate package. For example, it may be overly difficult to
391+ to implement as a separate package (for example, it may be overly difficult to
392392 design an IO package to be completely decoupled from OpenSSL, with opt-in via
393- the inclusion of a separate package.
393+ the inclusion of a separate package) .
394394
395395In almost all cases, it is an antipattern to use these features outside of
396396high-level packages that are designed for curation. If a feature is optional, it
@@ -417,16 +417,16 @@ Your project can optionally contain folders named `examples`, `tests`, and
417417integration tests, and benchmarks respectively.
418418
419419``` notrust
420- ▾ src/ # directory containing source files
421- lib.rs # the main entry point for libraries and packages
422- main.rs # the main entry point for projects producing executables
423- ▾ bin/ # (optional) directory containing additional executables
420+ ▾ src/ # directory containing source files
421+ lib.rs # the main entry point for libraries and packages
422+ main.rs # the main entry point for projects producing executables
423+ ▾ bin/ # (optional) directory containing additional executables
424424 *.rs
425- ▾ examples/ # (optional) examples
425+ ▾ examples/ # (optional) examples
426426 *.rs
427- ▾ tests/ # (optional) integration tests
427+ ▾ tests/ # (optional) integration tests
428428 *.rs
429- ▾ benches/ # (optional) benchmarks
429+ ▾ benches/ # (optional) benchmarks
430430 *.rs
431431```
432432
@@ -446,14 +446,15 @@ You can run individual examples with the command `cargo run --example
446446
447447When you run ` cargo test ` , Cargo will:
448448
449- * Compile and run your library’s unit tests, which are in files reachable from
450- ` lib.rs ` . Any sections marked with ` #[cfg(test)] ` will be included.
451- * Compile and run your library’s documentation tests, which are embedded inside
452- of documentation blocks.
453- * Compile and run your library’s [ integration tests] ( #integration-tests ) .
454- * Compile your library’s examples.
449+ * compile and run your library’s unit tests, which are in the files reachable
450+ from ` lib.rs ` (naturally, any sections marked with ` #[cfg(test)] ` will be
451+ considered at this stage);
452+ * compile and run your library’s documentation tests, which are embedded inside
453+ of documentation blocks;
454+ * compile and run your library’s [ integration tests] ( #integration-tests ) ; and
455+ * compile your library’s examples.
455456
456- ## Integration tests
457+ ## Integration Tests
457458
458459Each file in ` tests/*.rs ` is an integration test. When you run ` cargo test ` ,
459460Cargo will compile each of these files as a separate crate. The crate can link
@@ -466,7 +467,7 @@ example, if you want several integration tests to share some code, you can put
466467the shared code in ` tests/common/mod.rs ` and then put ` mod common; ` in each of
467468the test files.
468469
469- # Configuring a target
470+ # Configuring a Target
470471
471472All of the ` [[bin]] ` , ` [lib] ` , ` [[bench]] ` , ` [[test]] ` , and ` [[example]] `
472473sections support similar configuration for specifying how a target should be
@@ -483,7 +484,7 @@ specified.
483484# is defaulted to the name of the package or project.
484485name = " foo"
485486
486- # This field points at where the crate is located, relative to the Cargo.toml.
487+ # This field points at where the crate is located, relative to the ` Cargo.toml` .
487488path = " src/lib.rs"
488489
489490# A flag for enabling unit tests for this target. This is used by `cargo test`.
@@ -504,9 +505,9 @@ doc = true
504505# for Cargo to correctly compile it and make it available for all dependencies.
505506plugin = false
506507
507- # If set to false, `cargo test` will omit the --test flag to rustc, which stops
508- # it from generating a test harness. This is useful when the binary being built
509- # manages the test runner itself.
508+ # If set to false, `cargo test` will omit the ` --test` flag to rustc, which
509+ # stops it from generating a test harness. This is useful when the binary being
510+ # built manages the test runner itself.
510511harness = true
511512```
512513
@@ -520,10 +521,9 @@ build by explicitly listing the library in your `Cargo.toml`:
520521
521522[lib ]
522523name = " ..."
523- # this could be “staticlib” as well
524- crate-type = [" dylib" ]
524+ crate-type = [" dylib" ] # could be `staticlib` as well
525525```
526526
527527The available options are ` dylib ` , ` rlib ` , and ` staticlib ` . You should only use
528- this option in a project. Cargo will always compile ** packages** (dependencies)
528+ this option in a project. Cargo will always compile packages (dependencies)
529529based on the requirements of the project that includes them.
0 commit comments