Rust

| Comments

Contents:

Installation #

See documentation.

To update Rust:

rustup update

To uninstall:

rustup self uninstall

Tools, Libraries #

Build tools:

Fun stuff:

Web:

Documentation #

Exercises #

Tutorials #

How-to #

Cargo #

To start a new project:

cargo new hello_world

To build:

cargo build

# To build for release:

cargo build --release

# Type checks (faster than "build"):

cargo check

To compile and execute the project:

cargo run

To update dependencies:

cargo update

To generate and show the documentation of all dependencies:

cargo doc --open

Language Server #

rustup component add rust-analyzer

Build executable scripts #

#!/usr/bin/env -S cargo +nightly -q -Zscript

---cargo
[package]
edition = "2024"

[dependencies]
anyhow = "1"
clap = { version = "4", features = ["derive"] }
---

use anyhow::Result;
use clap::Parser;

#[derive(Parser)]
struct Args {
    name: String,
}

fn main() -> Result<()> {
    let args = Args::parse();
    println!("Hello, {}!", args.name);
    Ok(())
}