Contents:
Installation #
See documentation.
To update Rust:
rustup update
To uninstall:
rustup self uninstall
Tools, Libraries #
Build tools:
- rust-clippy: linting for catching common mistakes;
- rustfmt: automatic code formatting;
Fun stuff:
Web:
Documentation #
- The Rust Programming Language: official book for beginners
- Rust by Example: another official book
- Learn Rust With Entirely Too Many Linked Lists
- Asynchronous Programming in Rust
- Rust Sokoban
- Tour of Rust
Exercises #
Tutorials #
- Choosing Rust - Intro to Rust and Ownership (YouTube video)
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(())
}