Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Create a Project¶
cargo init
cargo new project_name
cargo new --lib project_nameInstall a Rust Crate (Package)¶
Install a Rust crate from GitHub (the default branch).
:::bash
cargo install --git https://github com/RustPython/RustPythonSpecify the option --version to install a specific version of a package.
:::bash
cargo install --version 0.8.1 evcxr_jupyterUpdate Dependencies¶
Please refer to cargo-update for the official tutorial.
Build a Project¶
Build the debug version of the project.
:::bash
cargo build Build the release version of the project.
:::bash
cargo build --releasehttps://
Run The Current Package¶
cargo run
cargo run --releaseFor more details, please refer to cargo-run .
Run Unit Tests¶
Please refer to Unit Test in Rust for more discussions.
Running Test¶
cargo test -- --test-threads=1
cargo test -- --show-output
cargo test -- --ignored
cargo test -- --ignored --show-output
cargo test --release
cargo test --release -- --ignored
Suppress Warnings Using RUSTFLAGS¶
Before cargo officially supports an option to disable warnings,
you can use the environment variable RUSTFLAGS to disable warnings during compiling.
:::bash
RUSTFLAGS=-Awarnings cargo build
RUSTFLAGS=-Awarnings cargo build --release
RUSTFLAGS=-Awarnings cargo test
RUSTFLAGS=-Awarnings cargo test --releaseA better way is to use the command cargo rustc
(instead of cargo build)
which allows users to pass compiler flags to it.
:::bash
cargo rustc --lib -- -AwarningsCargo Extensions / Addons¶
Please refer to Dev Tools for Rust for detailed discussions.