A systematic tutorial for learning Rust from scratch, helping you master the Rust programming language through examples and practice.
中文 | English
This book is built with mdBook and covers a complete learning path from Rust basics to advanced applications. Through practical examples and hands-on projects, it helps developers systematically learn and master Rust programming.
- Chapter 01: Rust Overview
- Chapter 02: Variables, Types, and Control Flow
- Chapter 03: Ownership and Borrowing
- Chapter 04: Structs and Enums
- Chapter 05: Generics and Traits
- Chapter 06: Error Handling
- Chapter 07: Collections
- Chapter 08: Module System
- Chapter 09: Concurrency
- Chapter 10: Network Programming
- Chapter 11: Database Operations
- Chapter 12: Web Development
- Chapter 13: Performance Optimization
- Chapter 14: Secure Programming
- Chapter 15: Testing and Debugging
- Chapter 16: Deployment and Operations
# Install mdBook
cargo install mdbook# Clone the repository
git clone <repository-url>
cd Learn-Rust-through-examples-
Directory Structure:
zh/- Chinese version (contains all Chinese chapters)en/- English version (manually add or translate English chapters)
-
Each language directory has its own
book.tomlconfiguration file andsrc/source directory. -
Build Process (Recommended): The repository root provides a
Makefilewith common targets. Example commands:
# Build English version (builds en/ and copies to book/en)
make build-en
# Build Chinese version (builds zh/ and copies to book/zh)
make build-zh
# Build all configured languages
make build-all
# Preview Chinese version (view in browser with live reload)
make serve-zh
# Preview English version (view in browser with live reload)
make serve-en
# Clean build artifacts
make clean- Manual Build (without Makefile):
# Build Chinese version
cd zh
mdbook build
cp -r book ../book/zh
# Build English version
cd ../en
mdbook build
cp -r book ../book/en- Manual Preview (without Makefile):
# Preview Chinese version (view at http://localhost:3000)
cd zh
mdbook serve
# Preview English version (view at http://localhost:3000)
cd en
mdbook serve-
Prerequisites: Ensure
mdbookis installed (e.g.,cargo install mdbook). The Makefile usesmdbook build, so it must be installed and available in PATH. -
Output Location: After building, static site files will be located at:
book/zh/- Chinese versionbook/en/- English version
Deploy these directories to a static hosting service (e.g., GitHub Pages) to provide multi-language access at paths
/zh/and/en/.
After building, open http://localhost:3000 in your browser to view.
The built HTML files are located in the book/ directory. You can directly open book/index.html in your browser.
rust_from_0/
├── book.toml # mdBook config (deprecated, use language-specific configs)
├── README # Project documentation (Chinese)
├── README.en.md # Project documentation (English)
├── Makefile # Multi-language build script
├── zh/ # Chinese version source files
│ ├── book.toml # Chinese version config
│ └── src/ # Chinese Markdown source files
│ ├── SUMMARY.md # Table of contents
│ ├── chapter_*.md # Chapter contents
│ └── chapter_*.rs # Code examples
├── en/ # English version source files
│ ├── book.toml # English version config
│ └── src/ # English Markdown source files
│ ├── SUMMARY.md # Table of contents
│ ├── chapter_*.md # Chapter contents
│ └── chapter_*.rs # Code examples
└── book/ # Build output directory
├── zh/ # Chinese version build artifacts
└── en/ # English version build artifacts
- Step by Step: Follow the chapter order, as each builds on previous knowledge
- Hands-on Practice: Run and modify example code to deepen understanding
- Complete Exercises: Practice problems in each chapter help solidify knowledge
- Reference Official Docs: Study alongside The Rust Programming Language
We welcome bug reports, improvement suggestions, and content contributions:
- Fork this repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under an open-source license. See the LICENSE file for details.
lihongchao
Email: singlemice@gmail.com
- Rust Official Website
- Rust Official Documentation
- Rust Standard Library Documentation
- mdBook Documentation
Happy Coding! 🦀