@@ -1,6 +1,6 @@
|
||||
# Dependencies
|
||||
|
||||
A package can depend on other packages by listing them in the `[dependencies]` section of its `Cargo.toml` file.
|
||||
A package can depend on other packages by listing them in the `[dependencies]` section of its `Cargo.toml` file.\
|
||||
The most common way to specify a dependency is by providing its name and version:
|
||||
|
||||
```toml
|
||||
@@ -8,7 +8,7 @@ The most common way to specify a dependency is by providing its name and version
|
||||
thiserror = "1"
|
||||
```
|
||||
|
||||
This will add `thiserror` as a dependency to your package, with a **minimum** version of `1.0.0`.
|
||||
This will add `thiserror` as a dependency to your package, with a **minimum** version of `1.0.0`.
|
||||
`thiserror` will be pulled from [crates.io](https://crates.io), Rust's official package registry.
|
||||
When you run `cargo build`, `cargo` will go through a few stages:
|
||||
|
||||
@@ -17,10 +17,10 @@ When you run `cargo build`, `cargo` will go through a few stages:
|
||||
- Compiling your project (your own code and the dependencies)
|
||||
|
||||
Dependency resolution is skipped if your project has a `Cargo.lock` file and your manifest files are unchanged.
|
||||
A lockfile is automatically generated by `cargo` after a successful round of dependency resolution: it contains
|
||||
the exact versions of all dependencies used in your project, and is used to ensure that the same versions are
|
||||
A lockfile is automatically generated by `cargo` after a successful round of dependency resolution: it contains
|
||||
the exact versions of all dependencies used in your project, and is used to ensure that the same versions are
|
||||
consistently used across different builds (e.g. in CI). If you're working on a project with multiple developers,
|
||||
you should commit the `Cargo.lock` file to your version control system.
|
||||
you should commit the `Cargo.lock` file to your version control system.
|
||||
|
||||
You can use `cargo update` to update the `Cargo.lock` file with the latest (compatible) versions of all your dependencies.
|
||||
|
||||
@@ -43,7 +43,7 @@ details on where you can get dependencies from and how to specify them in your `
|
||||
## Dev dependencies
|
||||
|
||||
You can also specify dependencies that are only needed for development—i.e. they only get pulled in when you're
|
||||
running `cargo test`.
|
||||
running `cargo test`.\
|
||||
They go in the `[dev-dependencies]` section of your `Cargo.toml` file:
|
||||
|
||||
```toml
|
||||
|
||||
Reference in New Issue
Block a user