
microsoft-rust-training
Comprehensive Rust training curriculum from Microsoft covering beginner to expert levels across 7 books with exercises, diagrams, and playgrounds.
- Installs
- 884
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/reason-machines/trending-skills --skill microsoft-rust-training- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads microsoft-rust-training automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Microsoft Rust Training
Skill by 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
# 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
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
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:
[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
// 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
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
// 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
// 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)
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
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
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
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
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
#[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
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
Typestate Pattern
use std::marker::PhantomData;
struct Locked;
struct Unlocked;
struct Safe<State> {
contents: String,
_state: PhantomData<State>,
}
impl Safe<Locked> {
fn new(contents: impl Into<String>) -> Self {
Safe { contents: contents.into(), _state: PhantomData }
}
fn unlock(self, _key: &str) -> Safe<Unlocked> {
Safe { contents: self.contents, _state: PhantomData }
}
}
impl Safe<Unlocked> {
fn get_contents(&self) -> &str { &self.contents }
fn lock(self) -> Safe<Locked> {
Safe { contents: self.contents, _state: PhantomData }
}
}
fn main() {
let safe = Safe::<Locked>::new("secret data");
// safe.get_contents(); // ERROR: method not available on Locked state
let open = safe.unlock("correct-key");
println!("{}", open.get_contents());
let _locked_again = open.lock();
}
Phantom Types for Unit Safety
use std::marker::PhantomData;
struct Meters;
struct Feet;
struct Distance<Unit> {
value: f64,
_unit: PhantomData<Unit>,
}
impl<Unit> Distance<Unit> {
fn new(value: f64) -> Self {
Distance { value, _unit: PhantomData }
}
fn value(&self) -> f64 { self.value }
}
impl Distance<Meters> {
fn to_feet(self) -> Distance<Feet> {
Distance::new(self.value * 3.28084)
}
}
fn main() {
let d_m: Distance<Meters> = Distance::new(100.0);
let d_f: Distance<Feet> = d_m.to_feet();
println!("{:.2} feet", d_f.value());
// Can't mix units — type system prevents it
}
Practices: Rust Engineering
Build Script (build.rs)
// build.rs — runs before compilation
fn main() {
// Tell Cargo to rerun if C source changes
println!("cargo:rerun-if-changed=src/native/lib.c");
// Compile a C library
cc::Build::new()
.file("src/native/lib.c")
.compile("native");
// Emit link search path
println!("cargo:rustc-link-search=native=/usr/local/lib");
println!("cargo:rustc-link-lib=ssl");
}
Cross-Compilation
# Add a target
rustup target add aarch64-unknown-linux-gnu
# Build for that target
cargo build --target aarch64-unknown-linux-gnu
# In .cargo/config.toml:
# [target.aarch64-unknown-linux-gnu]
# linker = "aarch64-linux-gnu-gcc"
Running Miri for Undefined Behavior Detection
# Install Miri
rustup component add miri
# Run tests under Miri
cargo miri test
# Run a specific binary under Miri
cargo miri run
Adding Content to a Book
SUMMARY.md Structure
# Summary
- [Introduction](./introduction.md)
- [Chapter 1: Ownership](./ch01-ownership.md)
- [Borrowing](./ch01-borrowing.md)
- [Lifetimes](./ch01-lifetimes.md)
- [Chapter 2: Types](./ch02-types.md)
Mermaid Diagrams in Chapters
```mermaid
graph TD
A[Value Created] --> B{Ownership Transfer?}
B -->|Move| C[New Owner]
B -->|Borrow| D[Temporary Reference]
C --> E[Original Invalid]
D --> F[Original Still Valid]
```
Rust Playground Links
You can run this example in the [Rust Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=fn+main()+%7B+println!(%22Hello%22)%3B+%7D).
xtask Automation
The xtask pattern lets you write build scripts in Rust instead of shell:
// xtask/src/main.rs — simplified pattern
use std::process::Command;
fn main() {
let task = std::env::args().nth(1).unwrap_or_default();
match task.as_str() {
"build" => build_all(),
"serve" => serve_all(),
"deploy" => deploy(),
"clean" => clean(),
_ => eprintln!("Unknown task: {task}"),
}
}
fn build_all() {
for book in &["c-cpp-book", "python-book", "async-book"] {
let status = Command::new("mdbook")
.args(["build", book])
.status()
.expect("mdbook not found");
assert!(status.success(), "Failed to build {book}");
}
}
Run with: cargo xtask build (configured in .cargo/config.toml as an alias).
CI/CD — GitHub Pages Deployment
# .github/workflows/pages.yml
name: Deploy to GitHub Pages
on:
push:
branches: [master]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install mdbook mdbook-mermaid
- run: cargo xtask deploy
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
Troubleshooting
mdbook command not found
cargo install mdbook mdbook-mermaid
# Ensure ~/.cargo/bin is in your PATH
export PATH="$HOME/.cargo/bin:$PATH"
Mermaid diagrams not rendering
# Ensure preprocessor is installed
cargo install mdbook-mermaid
# Verify book.toml has:
# [preprocessor.mermaid]
# command = "mdbook-mermaid"
Port already in use
# Specify a different port
mdbook serve --port 3001
Build fails on specific book
cd <book-name>
mdbook build 2>&1 # See full error output
Miri test failures
# Update Miri to latest nightly
rustup update nightly
rustup component add miri --toolchain nightly
cargo +nightly miri test
Cross-compilation linker errors
# Install cross (Docker-based cross compilation)
cargo install cross
cross build --target aarch64-unknown-linux-gnu
Reading Path Recommendations
New to Rust, coming from Python:
python-book → async-book → rust-patterns-book
Coming from C/C++:
c-cpp-book → rust-patterns-book → type-driven-correctness-book
Coming from C#/Java:
csharp-book → async-book → engineering-book
Already know Rust basics:
rust-patterns-book → type-driven-correctness-book → engineering-book
Production Rust:
engineering-book + async-book (cancellation safety chapters)
License
Dual-licensed under MIT and CC-BY-4.0. Code examples are MIT; prose and diagrams are CC-BY-4.0.
FAQ
What does the microsoft-rust-training skill do?
Comprehensive Rust training curriculum from Microsoft covering beginner to expert levels across 7 books with exercises, diagrams, and playgrounds.
How do I install microsoft-rust-training?
Run npx skills add https://github.com/reason-machines/trending-skills --skill microsoft-rust-training in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/microsoft-rust-training/ (personal) or .claude/skills/microsoft-rust-training/ (project).
Which AI agents can use microsoft-rust-training?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is microsoft-rust-training safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains microsoft-rust-training?
It is published by reason-machines in reason-machines/trending-skills. It has 884 recorded installs.
More from reason-machines/trending-skills
openclaw-control-center
reason-machines/trending-skills
Local-first, security-first control center for OpenClaw agents — visibility dashboard with readonly defaults, token attribution, collaboration tracing, and safe write operations.
inkos-multi-agent-novel-writing
reason-machines/trending-skills
Multi-agent CLI system for autonomous novel writing, auditing, and revision with human review gates
claude-hud-statusline
reason-machines/trending-skills
A Claude Code plugin that displays a real-time HUD showing context usage, active tools, running agents, and todo progress in your terminal statusline.
understand-anything-knowledge-graph
reason-machines/trending-skills
Turn any codebase into an interactive knowledge graph using Claude Code skills — explore, search, and ask questions about any project visually.
agency-agents-ai-specialists
reason-machines/trending-skills
A collection of specialized AI agent personalities for Claude Code, Cursor, Aider, Windsurf, and other AI coding tools — covering engineering, design, marketing, sales, and more.
agent-browser-automation
reason-machines/trending-skills
Headless browser automation CLI for AI agents using native Rust binary with Chrome DevTools Protocol
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.