English | 简体中文
Hello Rust Tutorial | GitHub Pages
A comprehensive sample project and tutorial for learning the Rust programming language, from basic syntax to advanced production-grade applications.
- 🌐 Official Tutorial: renyan.org/hello/rust
- 📚 GitHub Pages: savechina.github.io/hello-rust
# Clone the project
git clone https://github.com/savechina/hello-rust.git
cd hello-rust
# Run basic examples
cargo run
# Run specific binary examples
cargo run --bin grpc_hello_serverCore Rust syntax and concepts for beginners:
| Module | Content |
|---|---|
| Variables & Expressions | Variable binding, mutability, basic expressions |
| Data Types | Integers, floats, booleans, chars, collections, date/time |
| Ownership | Ownership rules, move semantics, borrowing & references |
| Lifetimes | Lifetime annotations, borrow checker, dangling references |
| Structs | Struct definitions, methods, associated functions |
| Enums | Enum definitions, pattern matching, Option/Result |
| Traits | Trait definitions, implementations, polymorphism |
| Trait Objects | Dynamic dispatch, dyn Trait, vtable mechanism |
| Generics | Generic functions, monomorphization, trait bounds |
| Closures | Closure syntax, environment capture, Fn/FnMut/FnOnce |
| Module System | Module organization, visibility, use statements |
| Threads & Concurrency | Thread spawning, channels, Mutex, Arc |
Deep dive into advanced Rust features and ecosystem:
| Module | Content |
|---|---|
| Smart Pointers | Box, Rc, RefCell, Arc, Weak, reference cycles |
| Error Handling | Result, ?, thiserror, anyhow, error propagation |
| Advanced Traits | Associated types, fully qualified syntax, Newtype pattern |
| Iterators | map, filter, collect, fold, custom iterators |
| Async Programming | Tokio runtime, async/await, Future trait |
| Database | SQLx async queries, Diesel ORM |
| Web Development | Axum web framework, Hyper HTTP, gRPC |
| Data Processing | Serde serialization, JSON, CSV, Rkyv zero-copy |
| System Programming | File operations, memory mapping, process management, atomics |
| Testing | Unit tests, integration tests, Mock, nextest |
| Macros | Declarative macros, procedural macros, hygiene |
| Module | Content |
|---|---|
| Algorithms | Linked list, pi calculation |
| LeetCode Solutions | Two Sum, Add Two Numbers |
| Awesome Examples | Service framework, message queues, template engines, DI |
- Rust 2024 Edition
- Async Runtime: Tokio
- Web Frameworks: Axum, Hyper, Tonic (gRPC)
- Databases: SQLx, Diesel
- Serialization: Serde, Rkyv
- Testing: Mockall, rspec, nextest
hello-rust/
├── src/
│ ├── basic/ # Basic tutorial example code
│ ├── advance/ # Advanced example code
│ ├── algo/ # Algorithm implementations
│ └── bin/ # 15 runnable binary examples (gRPC, UDS, Stdio IPC)
├── crates/
│ ├── awesome/ # Production-grade service framework (DI, Consul, gRPC)
│ ├── leetcode/ # LeetCode solutions
│ └── macros/ # Procedural macro examples (#[log])
└── docs/ # mdBook tutorial documentation (Chinese)
MIT License