- ./Software Engineering
- Blog - Official blog
- Crates.io - Public package repository
- Discord - Official discord server
- Docs.rs - Documentation host for crates
- Documentation - Official documentation
- Forum - Official forum
- Official site
- Playground - Run code on the web
- Reddit /r/rust
- RFCs
##rust
@ irc.libera.chat - IRC channel- rustup - Toolchain installer and manager
- Hands-on Rust - Effective Learning through 2D Game Development and Play
- Programming Rust, 2nd Edition (2021)
- Rust for Rustaceans (2021)
- The Little Book of Rust Macros
- The Rust Programming Language (2019)
- RefCell and the Interior Mutability Pattern
- Shared-State Concurrency
Read a local copy of "The Rust Programming Language" book in a web browser with:
rustup doc --book
- Finding Closure in Rust
- How to Idiomatically Use Global Variables in Rust
- Learn Rust With Entirely Too Many Linked Lists
- Learning about Rust's next, peek, and windows
- min-sized-rust - Minimize the size of a Rust binary
- Playing with tui-rs - Covers async + TUI
- Rust and TUI: Building a command-line interface in Rust
- Rust's Rules Are Made to Be Broken
Install system packages
# Make sure rust isn't installed, because we'll use `rustup` to manage rust and cargo installations
# Linux: apt remove cargo rust
# macOS: brew uninstall rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Ensure that ~/.cargo/env
is sourced in your environment. rustup
may update ~/.bashrc
, ~/.profile
, and/or ~/.zshenv
accordingly, but you may wish to modify these files according to your needs.
if [[ -f "${HOME}/.cargo/env" ]]; then
source "${HOME}/.cargo/env"
fi
Update Rust on the stable, beta, or nightly channel
#channel=beta
#channel=nightly
channel=stable
rustup update ${channel}
rustup default ${channel}
Create a project
# Use the binary template by default: --bin
cargo new ${project_name}
# Or use the library template: --lib
# cargo new --lib ${library_project_name}
cd ${project_name}
vim Cargo.toml
# Use the toolchain from the nightly channel for this project/directory
rustup override set nightly
cargo build
cargo run
Features and crate-level configuration:
// Requires Rust from the nightly channel as of rustc 1.59.0-nightly (e012a191d 2022-01-06)
#![feature(mixed_integer_ops)]
// Allow modules to have the same name as their parent module
#![allow(clippy::module_inception)]
// Show more lint warnings
#![warn(clippy::all, clippy::pedantic)]
- cargo-make - Task runner and build tool
- Specifying features
# List features enabled for each dependency
cargo tree -f "{p} {f}"
# More verbose version of the above
cargo tree -e features
- CodeLLDB extension - Debugger
- Rust extension - Language support. Conflicts with Rust-analyzer extension.
- Rust-analyzer extension - Language support (experimental, but recommended). Conflicts with Rust extension.
- Tasks
./.vscode/tasks.json
:
{
"version": "2.0.0",
"tasks": [
{
"label": "cargo build",
"type": "shell",
"command": "cargo build",
"args": [],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "cargo run",
"type": "shell",
"command": "cargo",
"args": [
"run"
],
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": []
}
]
}
Name | Description |
---|---|
anyhow | Concrete Error type built on std::error::Error |
clap | Parse command line arguments |
chrono | Date and time library |
chrono-tz | Timezone library |
crossterm | Library for controlling terminals |
cursive | Text User Interface (TUI) library. (Comparison to tui). |
enum-iterator | #[derive(IntoEnumIterato) for enums |
gtk-rs | GTK4, Cairo, glib, etc bindings |
OnceCell | Single assignment cells and lazy values |
rand | Generate random numbers |
Serde JSON | Serialize and deserialize JSON |
strum | Various #[derive(...)] for enums |
tempfile | Create temporary files or directories |
tera | Template engine inspired by Jinja2 |
tokio | Async runtime, including IO, networking, scheduling, and timers |
tui | Text User Interface (TUI) library. (Comparison to cursive). |
uuid | Generate and parse UUIDs |
- bevy - Game engine
$ cargo build
Compiling space_time_rewind v0.1.0 (/home/andornaut/src/github.com/andornaut/space-time-rewind)
thread 'rustc' panicked at 'failed to lookup `SourceFile` in new context', compiler/rustc_query_impl/src/on_disk_cache.rs:514:22
Fix: cargo clean && cargo build