Rust

Install Rust using rustup, manage toolchains, and verify cargo for local development before deploying to Discloud.

🧾 Overview

Rust provides performance, memory safety, and predictable resource usage for APIs, workers, and bots. Install with rustup to manage toolchains locally before deploying.


📥 Installation (choose your OS)

1

Download the installer: https://win.rustup.rs/ (or run command below in PowerShell)

2

Run and accept defaults (installs to user profile).

Verify

rustc --version
cargo --version

Update Toolchain

rustup update

🧰 Toolchains & Components

1

List installed

rustup toolchain list
2

Add nightly (optional)

rustup toolchain install nightly
3

Set default

rustup default stable
4

Add components (example)

rustup component add clippy rustfmt

🗂 Project Init

Create new project:

cargo new myapp
cd myapp
cargo build

Run:

cargo run

Format & lint:

cargo fmt -- --check
cargo clippy -- -D warnings

🗃 Common Cargo Commands

cargo new api-service          # create binary project
cargo build --release          # optimized build
cargo run                      # build + run
cargo test                     # run tests
cargo update                   # update dependency lock
cargo tree                     # dependency graph (requires cargo-tree)
cargo doc --open               # build docs locally

Install cargo tree (if missing):

cargo install cargo-tree

📦 Dependency Management

Dependencies declared in Cargo.toml under [dependencies]:

[dependencies]
reqwest = { version = "0.12", features = ["json"] }
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

Update lockfile:

cargo update

🔄 Updating

rustup update            # update all toolchains
rustup self update       # update rustup itself

Last updated