2022-07-27 12:00:12 +01:00
|
|
|
# cargo add
|
|
|
|
|
2023-10-29 08:54:53 +00:00
|
|
|
> Add dependencies to a Rust project's `Cargo.toml` manifest.
|
2022-07-27 12:00:12 +01:00
|
|
|
> More information: <https://doc.rust-lang.org/cargo/commands/cargo-add.html>.
|
|
|
|
|
|
|
|
- Add the latest version of a dependency to the current project:
|
|
|
|
|
|
|
|
`cargo add {{dependency}}`
|
|
|
|
|
|
|
|
- Add a specific version of a dependency:
|
|
|
|
|
|
|
|
`cargo add {{dependency}}@{{version}}`
|
|
|
|
|
|
|
|
- Add a dependency and enable one or more specific features:
|
|
|
|
|
|
|
|
`cargo add {{dependency}} --features {{feature_1}},{{feature_2}}`
|
|
|
|
|
|
|
|
- Add an optional dependency, which then gets exposed as a feature of the crate:
|
|
|
|
|
|
|
|
`cargo add {{dependency}} --optional`
|
|
|
|
|
|
|
|
- Add a local crate as a dependency:
|
|
|
|
|
2023-10-29 08:54:53 +00:00
|
|
|
`cargo add --path {{path/to/crate_directory}}`
|
2022-07-27 12:00:12 +01:00
|
|
|
|
|
|
|
- Add a development or build dependency:
|
|
|
|
|
|
|
|
`cargo add {{dependency}} --{{dev|build}}`
|
|
|
|
|
|
|
|
- Add a dependency with all default features disabled:
|
|
|
|
|
|
|
|
`cargo add {{dependency}} --no-default-features`
|