cargo

Cargo is the rust package manager. It has a bunch of default settings, but those are silly. Using the path field in lib and bin we can override the siliest ones.

Example

[package]
name = "swagger_to_md"
version = "1.0.0"
description = "Transform swagger to markdown"
keywords = ["swagger","markdown","transform","md","compile","html"]

[lib]
name = "swagger_to_md"
path = "main.rs"

[[bin]]
name = "swagger-to-md"
path = "bin/cli.rs"

[dependencies]

Lib

Libs are libraries. All it needs to do is expose a bunch of functions.

Bin

bin can have multiple multiple exports. Each command must reference a path and have an export name. Each file must expose a main function.

Pinning versions

To pin versions in Cargo.toml the cargo-edit command must be exposed to add cargo add. This pulls the latest version of a dep from crates.io and stores it in Cargo.toml.

Dont't touch the network

$ cargo run --frozen

Install latest cargo version

$ rustup override set nightly

Use last known good cargo version

$ rustup override set $(<rustc-version)

Incremental compilation

$ CARGO_INCREMENTAL=1 cargo <command>
$ rustc -Zincremental=<path> <other arguments>

See Also

results matching ""

    No results matching ""