Skip to content

tyxben/rust-thinking

Repository files navigation

Rust Thinking

A Rust Learning Path Designed for the AI Era

Rust License Status

What is This?

Rust Thinking is not just another Rust tutorial. It's a comprehensive learning path designed to train your programming mind in the AI era.

When AI can generate code instantly, what separates good developers from great ones?

  • 🧠 Logical Thinking: Deep understanding of language semantics
  • 👁️ Code Review: Spotting hidden bugs in AI-generated code
  • 🔧 Problem Decomposition: Breaking complex problems into manageable pieces
  • 🎯 System Design: Building reliable, efficient systems

This repository teaches Rust not as syntax, but as a tool to develop these critical skills.

Why Rust?

Rust's strict compiler is your best teacher:

  • Forces you to think about ownership, borrowing, and concurrency
  • Reveals design flaws at compile-time, not runtime
  • Makes implicit assumptions explicit
  • Perfect for training rigorous thinking

AI时代的真正竞争力不在于能否写代码,而在于能否 review 代码、发现问题、设计系统。

Learning Path (学习路径)

00-why-rust/                → 为什么选择 Rust
    └── AI 生成 bug 的真实案例

01-basics/                  → 基础概念
    ├── 01-hello-cargo         变量、输出、类型推断
    ├── 02-types-and-structs   类型系统、结构体、枚举
    ├── 03-ownership           ⭐ 所有权(最核心)
    ├── 04-error-handling      Option、Result、? 运算符
    └── 05-pattern-matching    match、if let、解构

02-intermediate/            → 进阶概念
    ├── 06-generics-traits     泛型与 Trait
    ├── 07-lifetimes           生命周期
    ├── 08-iterators-closures  迭代器与闭包
    ├── 09-concurrency         并发编程
    └── 10-async-tokio         异步编程与 Tokio

03-projects/                → 实战项目
    ├── mini-kv                简单 KV 存储
    ├── merkle-tree            Merkle 树
    ├── wasm-crypto            加密工具(概念演示)
    └── zk-verifier            ZK 验证器(概念演示)

ai-review-cases/            ⭐ 核心价值
    ├── case-01-deadlock       死锁分析与修复
    ├── case-02-memory-leak    内存泄漏与 Rc/Weak
    └── case-03-security       安全性审查

exercises/                  → 练习题
    ├── beginner/              7 道初级练习
    ├── intermediate/          7 道中级练习
    ├── advanced/              4 道高级练习
    └── solutions/             参考答案

articles/                   → 配套文章
    └── 5 篇深度文章

Quick Start

Prerequisites

Run Examples

# 运行某个模块
cd 01-basics/03-ownership/
cargo run                        # 运行主程序
cargo run --example move_demo    # 运行示例

# 运行项目
cd 03-projects/mini-kv/
cargo run

# 运行异步模块(需要 tokio)
cd 02-intermediate/10-async-tokio/
cargo run

Read the Case Studies

Start with ai-review-cases/ - these are real problems AI made (or commonly makes):

  1. Deadlock in Arc<Mutex>
  2. Memory Leak with Rc Cycles
  3. Security Review of Unsafe Code

Directory Structure (目录结构说明)

Directory Purpose Difficulty
00-why-rust/ 为什么用 Rust Beginner
01-basics/ Rust 基础概念(5 个模块) Beginner
02-intermediate/ 进阶特性(5 个模块) Intermediate
03-projects/ 实战项目(4 个项目) Intermediate-Advanced
ai-review-cases/ AI 代码审查案例(3 个案例) Intermediate
exercises/ 自测练习题(18 道 + 解答) Mixed
articles/ 配套文章索引 Reference

Featured Content

AI Code Review Cases (AI 代码审查案例)

This is where the real learning happens. We take actual patterns from AI-generated code and analyze:

  • What went wrong (什么地方错了)
  • Why the compiler missed it (为什么编译器没有发现)
  • How to prevent it (如何避免)
  • Deep principles (背后的深层原理)

Learning Resources (学习资源)

Articles Index (文章索引) - See articles/README.md

  • Rust ownership explained for AI era developers
  • Code review skills every developer needs
  • Concurrency patterns that AI often gets wrong
  • And more...

How to Learn

Option 1: Deep Dive Path (系统学习)

1. Start:      00-why-rust/                → 理解动机
2. Foundation: 01-basics/ (01→05)          → 掌握基础
3. Practice:   exercises/beginner/          → 初级练习
4. Real Cases: ai-review-cases/            → 真实案例学习
5. Intermediate: 02-intermediate/ (06→10)  → 进阶概念
6. Practice:   exercises/intermediate/      → 中级练习
7. Projects:   03-projects/                → 实战项目
8. Advanced:   exercises/advanced/          → 高级挑战

Option 2: Case-Driven Path (案例驱动)

1. Start with ai-review-cases/case-01-deadlock/
2. Jump to 01-basics/03-ownership/ (for foundation)
3. Explore other cases
4. Fill gaps with specific modules

Key Features

Practical: Real AI-generated bugs, not contrived examples ✅ Deep: Understand why, not just howCode-first: Every concept has runnable examples ✅ Interactive: Exercises with solutions ✅ Bilingual: Chinese + English throughout ✅ Projects: 4 hands-on projects to apply knowledge

Contributing

We welcome contributions! Whether you:

  • Found a bug in examples
  • Have a better explanation
  • Want to add a case study
  • Spotted a typo

See CONTRIBUTING.md for guidelines.

License

MIT License - See LICENSE

Copyright (c) 2024 tyxben

You're free to use, modify, and distribute this material for learning purposes.

Roadmap

  • Complete 01-basics/ modules (5/5)
  • Complete 02-intermediate/ modules (5/5)
  • Complete 03-projects/ (4 projects)
  • Complete ai-review-cases/ (3 cases)
  • Complete exercises/ (18 exercises + solutions)
  • Interactive exercises with auto-grading
  • Build web companion (for better UX)
  • Video explanations (selected chapters)

Stay Connected


Remember: In the AI era, your value is not in writing code—it's in understanding, reviewing, and improving code.

Rust teaches you how.

Happy learning! 🦀

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages