Cargo (software)
Cargo | |
---|---|
Basic data
|
|
Maintainer | Rust Project Developers |
Current version |
0.46.1 ( July 30, 2020 ) |
programming language | Rust |
category | Package management |
License | MIT license |
doc.rust-lang.org/stable/cargo/ |
Cargo is package management software for Rust packages called Crate . Cargo is installed by rustup
default using the Rust toolchain installation program ; Cargo uses the TOML file format to manage package metadata .
Functions
Cargo is used as the central tool for managing Rust packages. It takes on the following tasks for each package:
- the management of the metadata about the package
- the resolution and compilation of the dependencies
- calling the reference compiler
rustc
with the appropriate parameters - the enforcement of Rust conventions for uniform package management
Package structure
Rust packages consist of a defined structure:
- the files Cargo.toml and Cargo.lock in the root directory
- the source code files in src /
- optional:
- Integration tests in tests /
- Examples in examples /
- Benchmarks in benches /
manifest
The package manifest is in the Cargo.toml and looks like this:
[package]
name = "hello_world"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
[dependencies]
regex = "1"
rand = { git = "https://github.com/rust-lang-nursery/rand.git" }
lazy_static = "*"
[dev-dependencies]
mysql = "16.0.1"
The category contains package
basic information about the package such as name and version, as well as the authors involved. The category dependencies
includes all the dependencies of the package, categories such as dev-dependencies
or profile.*
allow you to specify separate settings for tests or similar scenarios.
The Cargo.lock file contains the exact revision data of the corresponding dependencies and is automatically generated and maintained by Cargo.
crates.io
crates.io | |
---|---|
languages | English |
Registration | no, only for uploading your own crates |
On-line | (currently active) |
https://crates.io |
The official repository for crates is hosted at crates.io . A GitHub account is required to upload your own crates . As of Rust 1.34.0, alternative repositories can also be integrated into Cargo, previously only crates.io could be used.
Web links
Individual evidence
- ↑ Release 0.46.1 . July 30, 2020 (accessed July 31, 2020).
- ↑ github.com .
- ↑ Why Cargo exists. Retrieved April 22, 2018 .
- ↑ Cargo.toml vs Cargo.lock. Retrieved April 22, 2019 .
- ^ The Manifest Format - The Cargo Book. Retrieved April 23, 2019 .
- ↑ Publishing on crates.io. Retrieved April 22, 2019 .
- ↑ Programming language: Rust 1.34 allows alternatives to crates.io. Retrieved April 22, 2019 .