2016-05-05 02:39:32 +01:00
|
|
|
# cargo
|
|
|
|
|
|
|
|
> Manage Rust projects and their module dependencies (crates).
|
2021-09-13 09:21:21 +01:00
|
|
|
> Some subcommands such as `cargo build` have their own usage documentation.
|
2019-06-03 01:06:36 +01:00
|
|
|
> More information: <https://crates.io/>.
|
2016-05-05 02:39:32 +01:00
|
|
|
|
|
|
|
- Search for crates:
|
|
|
|
|
|
|
|
`cargo search {{search_string}}`
|
|
|
|
|
|
|
|
- Install a crate:
|
|
|
|
|
|
|
|
`cargo install {{crate_name}}`
|
|
|
|
|
|
|
|
- List installed crates:
|
|
|
|
|
|
|
|
`cargo install --list`
|
|
|
|
|
2019-01-13 04:00:16 +00:00
|
|
|
- Create a new binary or library Rust project in the current directory:
|
2016-05-05 02:39:32 +01:00
|
|
|
|
2019-01-13 04:00:16 +00:00
|
|
|
`cargo init --{{bin|lib}}`
|
2016-05-05 02:39:32 +01:00
|
|
|
|
2019-01-13 04:00:16 +00:00
|
|
|
- Create a new binary or library Rust project in the specified directory:
|
2016-05-05 02:39:32 +01:00
|
|
|
|
2019-01-13 04:00:16 +00:00
|
|
|
`cargo new {{path/to/directory}} --{{bin|lib}}`
|
2016-05-05 02:39:32 +01:00
|
|
|
|
|
|
|
- Build the Rust project in the current directory:
|
|
|
|
|
|
|
|
`cargo build`
|
|
|
|
|
2019-10-27 11:25:50 +00:00
|
|
|
- Build using a specific number of threads (default is the number of CPU cores):
|
2016-05-05 02:39:32 +01:00
|
|
|
|
2021-09-11 08:53:04 +01:00
|
|
|
`cargo build --jobs {{number_of_threads}}`
|