tldr/pages/common/cargo.md

34 lines
697 B
Markdown
Raw Normal View History

2016-05-05 02:39:32 +01:00
# cargo
> Rust package manager.
> Manage Rust projects and their module dependencies (crates).
> 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
`cargo build -j {{jobs}}`