restructure
This commit is contained in:
parent
ef7661245b
commit
598a10bc28
182 changed files with 342 additions and 336 deletions
|
@ -3,7 +3,7 @@ obj: application
|
|||
---
|
||||
|
||||
# cargo
|
||||
[Cargo](https://doc.rust-lang.org/cargo/) is the official package manager for the [Rust](../../programming/languages/Rust.md) programming language. It serves as a build system, package manager, and dependency manager for [Rust](../../programming/languages/Rust.md) projects. Cargo makes it easy to manage, build, and distribute [Rust](../../programming/languages/Rust.md) projects, handling tasks such as compiling code, managing dependencies, and running tests.
|
||||
[Cargo](https://doc.rust-lang.org/cargo/) is the official package manager for the [Rust](../../dev/programming/languages/Rust.md) programming language. It serves as a build system, package manager, and dependency manager for [Rust](../../dev/programming/languages/Rust.md) projects. Cargo makes it easy to manage, build, and distribute [Rust](../../dev/programming/languages/Rust.md) projects, handling tasks such as compiling code, managing dependencies, and running tests.
|
||||
|
||||
## `cargo add`
|
||||
Add dependencies to a `Cargo.toml` manifest file
|
||||
|
@ -59,7 +59,7 @@ Remove artifacts that cargo has generated in the past
|
|||
Usage: `cargo clean`
|
||||
|
||||
## `cargo clippy`
|
||||
Checks a package to catch common mistakes and improve your [Rust](../../programming/languages/Rust.md) code.
|
||||
Checks a package to catch common mistakes and improve your [Rust](../../dev/programming/languages/Rust.md) code.
|
||||
|
||||
### Options
|
||||
| Option | Description |
|
||||
|
@ -106,7 +106,7 @@ Create a new cargo package in an existing directory
|
|||
| `--name <NAME>` | Set the resulting package name, defaults to the directory name |
|
||||
|
||||
## `cargo install`
|
||||
Install a [Rust](../../programming/languages/Rust.md) binary. Default location is `$HOME/.cargo/bin`
|
||||
Install a [Rust](../../dev/programming/languages/Rust.md) binary. Default location is `$HOME/.cargo/bin`
|
||||
|
||||
### Options
|
||||
| Option | Description |
|
||||
|
@ -217,7 +217,7 @@ Execute all unit and integration tests and build examples of a local package
|
|||
Display a tree visualization of a dependency graph
|
||||
|
||||
## `cargo uninstall`
|
||||
Remove a [Rust](../../programming/languages/Rust.md) binary
|
||||
Remove a [Rust](../../dev/programming/languages/Rust.md) binary
|
||||
|
||||
## `cargo update`
|
||||
Update dependencies as recorded in the local lock file
|
||||
|
@ -232,8 +232,8 @@ Every manifest file consists of the following sections:
|
|||
- [`name`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-name-field) — The name of the package.
|
||||
- [`version`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-version-field) — The version of the package.
|
||||
- [`authors`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field) — The authors of the package.
|
||||
- [`edition`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-edition-field) — The [Rust](../../programming/languages/Rust.md) edition.
|
||||
- [`rust-version`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field) — The minimal supported [Rust](../../programming/languages/Rust.md) version.
|
||||
- [`edition`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-edition-field) — The [Rust](../../dev/programming/languages/Rust.md) edition.
|
||||
- [`rust-version`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field) — The minimal supported [Rust](../../dev/programming/languages/Rust.md) version.
|
||||
- [`description`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-description-field) — A description of the package.
|
||||
- [`documentation`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-documentation-field) — [URL](../../internet/URL.md) of the package documentation.
|
||||
- [`readme`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-readme-field) — Path to the package’s README file.
|
||||
|
@ -275,7 +275,7 @@ Every manifest file consists of the following sections:
|
|||
- [`[workspace]`](https://doc.rust-lang.org/cargo/reference/workspaces.html) — The workspace definition.
|
||||
|
||||
## Build Scripts
|
||||
Some packages need to compile third-party non-[Rust](../../programming/languages/Rust.md) code, for example C libraries. Other packages need to link to C libraries which can either be located on the system or possibly need to be built from source. Others still need facilities for functionality such as code generation before building (think parser generators).
|
||||
Some packages need to compile third-party non-[Rust](../../dev/programming/languages/Rust.md) code, for example C libraries. Other packages need to link to C libraries which can either be located on the system or possibly need to be built from source. Others still need facilities for functionality such as code generation before building (think parser generators).
|
||||
|
||||
Cargo does not aim to replace other tools that are well-optimized for these tasks, but it does integrate with them with custom build scripts. Placing a file named `build.rs` in the root of a package will cause Cargo to compile that script and execute it just before building the package.
|
||||
|
||||
|
@ -294,7 +294,7 @@ fn main() {
|
|||
## Environment Variables
|
||||
When the build script is run, there are a number of inputs to the build script, all passed in the form of [environment variables](../../linux/Environment%20Variables.md).
|
||||
|
||||
Cargo exposes these [environment variables](../../linux/Environment%20Variables.md) to your crate when it is compiled. Note that this applies for running binaries with `cargo run` and `cargo test` as well. To get the value of any of these variables in a [Rust](../../programming/languages/Rust.md) program, do this:
|
||||
Cargo exposes these [environment variables](../../linux/Environment%20Variables.md) to your crate when it is compiled. Note that this applies for running binaries with `cargo run` and `cargo test` as well. To get the value of any of these variables in a [Rust](../../dev/programming/languages/Rust.md) program, do this:
|
||||
|
||||
```rust
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
|
@ -315,7 +315,7 @@ Exposed environment variables:
|
|||
- `CARGO_PKG_REPOSITORY` — The repository from the manifest of your package.
|
||||
- `CARGO_PKG_LICENSE` — The license from the manifest of your package.
|
||||
- `CARGO_PKG_LICENSE_FILE` — The license file from the manifest of your package.
|
||||
- `CARGO_PKG_RUST_VERSION` — The [Rust](../../programming/languages/Rust.md) version from the manifest of your package. Note that this is the minimum [Rust](../../programming/languages/Rust.md) version supported by the package, not the current [Rust](../../programming/languages/Rust.md) version.
|
||||
- `CARGO_PKG_RUST_VERSION` — The [Rust](../../dev/programming/languages/Rust.md) version from the manifest of your package. Note that this is the minimum [Rust](../../dev/programming/languages/Rust.md) version supported by the package, not the current [Rust](../../dev/programming/languages/Rust.md) version.
|
||||
- `CARGO_PKG_README` — Path to the README file of your package.
|
||||
- `CARGO_CRATE_NAME` — The name of the crate that is currently being compiled. It is the name of the Cargo target with `-` converted to `_`, such as the name of the library, binary, example, integration test, or benchmark.
|
||||
- `CARGO_BIN_NAME` — The name of the binary that is currently being compiled. Only set for binaries or binary examples. This name does not include any file extension, such as `.exe`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue