microsoft-rust-training
Comprehensive Rust training curriculum from Microsoft covering beginner to expert levels across 7 books with exercises, diagrams, and playgrounds.
What this skill does
# Microsoft Rust Training
> Skill by [ara.so](https://ara.so) โ Daily 2026 Skills collection.
A collection of seven structured Rust training books maintained by Microsoft, covering Rust from multiple entry points (C/C++, C#/Java, Python backgrounds) through deep dives on async, advanced patterns, type-level correctness, and engineering practices. Each book contains 15โ16 chapters with Mermaid diagrams, editable Rust playgrounds, and exercises.
---
## Book Catalog
| Book | Level | Focus |
|------|-------|-------|
| `c-cpp-book` | ๐ข Bridge | Move semantics, RAII, FFI, embedded, no_std |
| `csharp-book` | ๐ข Bridge | C#/Java/Swift โ ownership & type system |
| `python-book` | ๐ข Bridge | Dynamic โ static typing, GIL-free concurrency |
| `async-book` | ๐ต Deep Dive | Tokio, streams, cancellation safety |
| `rust-patterns-book` | ๐ก Advanced | Pin, allocators, lock-free structures, unsafe |
| `type-driven-correctness-book` | ๐ฃ Expert | Type-state, phantom types, capability tokens |
| `engineering-book` | ๐ค Practices | Build scripts, cross-compilation, CI/CD, Miri |
---
## Installation & Setup
### Prerequisites
```bash
# Install Rust via rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install mdBook and Mermaid preprocessor
cargo install mdbook mdbook-mermaid
```
### Clone and Build
```bash
git clone https://github.com/microsoft/RustTraining.git
cd RustTraining
# Build all books into site/
cargo xtask build
# Serve all books locally at http://localhost:3000
cargo xtask serve
# Build for GitHub Pages deployment (outputs to docs/)
cargo xtask deploy
# Clean build artifacts
cargo xtask clean
```
### Serve a Single Book
```bash
cd c-cpp-book && mdbook serve --open # http://localhost:3000
cd python-book && mdbook serve --open
cd async-book && mdbook serve --open
```
---
## Repository Structure
```
RustTraining/
โโโ c-cpp-book/
โ โโโ book.toml
โ โโโ src/
โ โโโ SUMMARY.md # Table of contents
โ โโโ *.md # Chapter files
โโโ csharp-book/
โโโ python-book/
โโโ async-book/
โโโ rust-patterns-book/
โโโ type-driven-correctness-book/
โโโ engineering-book/
โโโ xtask/ # Build automation (cargo xtask)
โ โโโ src/main.rs
โโโ docs/ # GitHub Pages output
โโโ site/ # Local preview output
โโโ .github/workflows/
โโโ pages.yml # Auto-deploy on push to master
```
---
## mdBook Configuration (`book.toml`)
Each book contains a `book.toml`. Example configuration pattern:
```toml
[book]
title = "Async Rust"
authors = ["Microsoft"]
language = "en"
src = "src"
[build]
build-dir = "../site/async-book"
[preprocessor.mermaid]
command = "mdbook-mermaid"
[output.html]
default-theme = "navy"
preferred-dark-theme = "navy"
git-repository-url = "https://github.com/microsoft/RustTraining"
edit-url-template = "https://github.com/microsoft/RustTraining/edit/master/{path}"
[output.html.search]
enable = true
```
---
## Key Rust Concepts Covered by Book
### Bridge: Rust for C/C++ Programmers
**Ownership & Move Semantics**
```rust
// C++ has copy by default; Rust moves by default
fn take_ownership(s: String) {
println!("{s}");
} // s is dropped here
fn main() {
let s = String::from("hello");
take_ownership(s);
// println!("{s}"); // ERROR: s was moved
// Use clone for explicit deep copy
let s2 = String::from("world");
let s3 = s2.clone();
println!("{s2} {s3}"); // Both valid
}
```
**RAII โ No Manual Memory Management**
```rust
use std::fs::File;
use std::io::{self, Write};
fn write_data(path: &str, data: &[u8]) -> io::Result<()> {
let mut file = File::create(path)?; // Opens file
file.write_all(data)?;
Ok(())
} // file automatically closed here โ no explicit close needed
```
**FFI Example**
```rust
// Calling C from Rust
extern "C" {
fn abs(x: i32) -> i32;
}
fn main() {
unsafe {
println!("abs(-5) = {}", abs(-5));
}
}
```
---
### Bridge: Rust for Python Programmers
**Static Typing with Type Inference**
```rust
// Python: x = [1, 2, 3]
// Rust infers the type from usage:
let mut numbers = Vec::new();
numbers.push(1_i32);
numbers.push(2);
numbers.push(3);
// Explicit when needed:
let numbers: Vec<i32> = vec![1, 2, 3];
```
**Error Handling (no exceptions)**
```rust
use std::num::ParseIntError;
fn double_number(s: &str) -> Result<i32, ParseIntError> {
let n = s.trim().parse::<i32>()?; // ? propagates error
Ok(n * 2)
}
fn main() {
match double_number("5") {
Ok(n) => println!("Doubled: {n}"),
Err(e) => println!("Error: {e}"),
}
}
```
**GIL-Free Concurrency**
```rust
use std::thread;
use std::sync::{Arc, Mutex};
fn main() {
let counter = Arc::new(Mutex::new(0));
let mut handles = vec![];
for _ in 0..10 {
let counter = Arc::clone(&counter);
let handle = thread::spawn(move || {
let mut num = counter.lock().unwrap();
*num += 1;
});
handles.push(handle);
}
for handle in handles {
handle.join().unwrap();
}
println!("Result: {}", *counter.lock().unwrap()); // 10
}
```
---
### Deep Dive: Async Rust
**Basic Async with Tokio**
```rust
use tokio::time::{sleep, Duration};
#[tokio::main]
async fn main() {
let result = fetch_data().await;
println!("{result}");
}
async fn fetch_data() -> String {
sleep(Duration::from_millis(100)).await;
"data loaded".to_string()
}
```
**Concurrent Tasks**
```rust
use tokio::task;
#[tokio::main]
async fn main() {
let (a, b) = tokio::join!(
task::spawn(async { expensive_computation(1).await }),
task::spawn(async { expensive_computation(2).await }),
);
println!("{} {}", a.unwrap(), b.unwrap());
}
async fn expensive_computation(n: u64) -> u64 {
tokio::time::sleep(std::time::Duration::from_millis(n * 100)).await;
n * 42
}
```
**Cancellation-Safe Streams**
```rust
use tokio_stream::{self as stream, StreamExt};
#[tokio::main]
async fn main() {
let mut s = stream::iter(vec![1, 2, 3, 4, 5]);
while let Some(value) = s.next().await {
println!("got {value}");
}
}
```
---
### Advanced: Rust Patterns
**Type-Safe Builder Pattern**
```rust
#[derive(Debug)]
struct Config {
host: String,
port: u16,
max_connections: usize,
}
struct ConfigBuilder {
host: String,
port: u16,
max_connections: usize,
}
impl ConfigBuilder {
fn new() -> Self {
Self {
host: "localhost".into(),
port: 8080,
max_connections: 100,
}
}
fn host(mut self, h: impl Into<String>) -> Self { self.host = h.into(); self }
fn port(mut self, p: u16) -> Self { self.port = p; self }
fn max_connections(mut self, m: usize) -> Self { self.max_connections = m; self }
fn build(self) -> Config {
Config { host: self.host, port: self.port, max_connections: self.max_connections }
}
}
fn main() {
let config = ConfigBuilder::new()
.host("0.0.0.0")
.port(9090)
.max_connections(500)
.build();
println!("{config:?}");
}
```
**Custom Allocator**
```rust
use std::alloc::{GlobalAlloc, Layout, System};
use std::sync::atomic::{AtomicUsize, Ordering};
static ALLOCATED: AtomicUsize = AtomicUsize::new(0);
struct TrackingAllocator;
unsafe impl GlobalAlloc for TrackingAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
ALLOCATED.fetch_add(layout.size(), Ordering::Relaxed);
System.alloc(layout)
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
ALLOCATED.fetch_sub(layout.size(), Ordering::Relaxed);
System.dealloc(ptr, layout)
}
}
#[global_allocator]
static A: TrackingAllocator = TrackingAllocator;
fn main() {
let _v: Vec<u8> = vec![0u8; 1024];
println!("Allocated: {} bytes", ALLOCATED.load(Ordering::Relaxed));
}
```
---
### Expert: Type-Driven Correctness
*Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only โ no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.