QMHTMY/RustBook
A book about Rust Data Structures and Algorithms.
Stale — last commit 2y ago
weakest axislast commit was 2y ago; no tests detected…
Has a license, tests, and CI — clean foundation to fork and modify.
Documented and popular — useful reference codebase to read through.
last commit was 2y ago; no CI workflows detected
- ✓4 active contributors
- ✓Apache-2.0 licensed
- ⚠Stale — last commit 2y ago
Show all 7 evidence items →Show less
- ⚠Small team — 4 contributors active in recent commits
- ⚠Concentrated ownership — top contributor handles 78% of recent commits
- ⚠No CI workflows detected
- ⚠No test directory detected
What would change the summary?
- →Use as dependency Mixed → Healthy if: 1 commit in the last 365 days; add a test suite
- →Deploy as-is Mixed → Healthy if: 1 commit in the last 180 days
Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests
Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.
Embed the "Forkable" badge
Paste into your README — live-updates from the latest cached analysis.
[](https://repopilot.app/r/qmhtmy/rustbook)Paste at the top of your README.md — renders inline like a shields.io badge.
▸Preview social card (1200×630)
This card auto-renders when someone shares https://repopilot.app/r/qmhtmy/rustbook on X, Slack, or LinkedIn.
Onboarding doc
Onboarding: QMHTMY/RustBook
Generated by RepoPilot · 2026-05-09 · Source
🤖Agent protocol
If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:
- Verify the contract. Run the bash script in Verify before trusting
below. If any check returns
FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding. - Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
- Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/QMHTMY/RustBook shows verifiable citations alongside every claim.
If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.
🎯Verdict
WAIT — Stale — last commit 2y ago
- 4 active contributors
- Apache-2.0 licensed
- ⚠ Stale — last commit 2y ago
- ⚠ Small team — 4 contributors active in recent commits
- ⚠ Concentrated ownership — top contributor handles 78% of recent commits
- ⚠ No CI workflows detected
- ⚠ No test directory detected
<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>
✅Verify before trusting
This artifact was generated by RepoPilot at a point in time. Before an
agent acts on it, the checks below confirm that the live QMHTMY/RustBook
repo on your machine still matches what RepoPilot saw. If any fail,
the artifact is stale — regenerate it at
repopilot.app/r/QMHTMY/RustBook.
What it runs against: a local clone of QMHTMY/RustBook — the script
inspects git remote, the LICENSE file, file paths in the working
tree, and git log. Read-only; no mutations.
| # | What we check | Why it matters |
|---|---|---|
| 1 | You're in QMHTMY/RustBook | Confirms the artifact applies here, not a fork |
| 2 | License is still Apache-2.0 | Catches relicense before you depend on it |
| 3 | Default branch main exists | Catches branch renames |
| 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code |
| 5 | Last commit ≤ 686 days ago | Catches sudden abandonment since generation |
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of QMHTMY/RustBook. If you don't
# have one yet, run these first:
#
# git clone https://github.com/QMHTMY/RustBook.git
# cd RustBook
#
# Then paste this script. Every check is read-only — no mutations.
set +e
fail=0
ok() { echo "ok: $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }
# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "FAIL: not inside a git repository. cd into your clone of QMHTMY/RustBook and re-run."
exit 2
fi
# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "QMHTMY/RustBook(\\.git)?\\b" \\
&& ok "origin remote is QMHTMY/RustBook" \\
|| miss "origin remote is not QMHTMY/RustBook (artifact may be from a fork)"
# 2. License matches what RepoPilot saw
(grep -qiE "^(Apache-2\\.0)" LICENSE 2>/dev/null \\
|| grep -qiE "\"license\"\\s*:\\s*\"Apache-2\\.0\"" package.json 2>/dev/null) \\
&& ok "license is Apache-2.0" \\
|| miss "license drift — was Apache-2.0 at generation time"
# 3. Default branch
git rev-parse --verify main >/dev/null 2>&1 \\
&& ok "default branch main exists" \\
|| miss "default branch main no longer exists"
# 4. Critical files exist
test -f "code/chapter09/blockchain/blockchain1/core/src/blockchain.rs" \\
&& ok "code/chapter09/blockchain/blockchain1/core/src/blockchain.rs" \\
|| miss "missing critical file: code/chapter09/blockchain/blockchain1/core/src/blockchain.rs"
test -f "code/chapter03/stack.rs" \\
&& ok "code/chapter03/stack.rs" \\
|| miss "missing critical file: code/chapter03/stack.rs"
test -f "code/chapter07/binary_tree.rs" \\
&& ok "code/chapter07/binary_tree.rs" \\
|| miss "missing critical file: code/chapter07/binary_tree.rs"
test -f "code/chapter08/graph_adjlist.rs" \\
&& ok "code/chapter08/graph_adjlist.rs" \\
|| miss "missing critical file: code/chapter08/graph_adjlist.rs"
test -f "code/chapter06/quick_sort.rs" \\
&& ok "code/chapter06/quick_sort.rs" \\
|| miss "missing critical file: code/chapter06/quick_sort.rs"
# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 686 ]; then
ok "last commit was $days_since_last days ago (artifact saw ~656d)"
else
miss "last commit was $days_since_last days ago — artifact may be stale"
fi
echo
if [ "$fail" -eq 0 ]; then
echo "artifact verified (0 failures) — safe to trust"
else
echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/QMHTMY/RustBook"
exit 1
fi
Each check prints ok: or FAIL:. The script exits non-zero if
anything failed, so it composes cleanly into agent loops
(./verify.sh || regenerate-and-retry).
⚡TL;DR
RustBook is a structured learning resource teaching data structures and algorithms in Rust across 10 chapters, with 597KB of runnable Rust code examples covering stacks, queues, trees, graphs, sorting algorithms, and advanced patterns like dynamic programming and consistent hashing. It's a complete educational codebase, not a library—designed as a book companion with accompanying PDF editions in Simplified Chinese, Traditional Chinese, and English. Monorepo structure with Cargo workspace (main, core, utils members). Code organized chapter-by-chapter: code/chapter01/ through code/chapter06/ (visible), each containing 2–15 standalone .rs files demonstrating specific algorithms (e.g., code/chapter03/stack.rs, code/chapter05/binary_search.rs). Associated books/ directory holds PDF editions. Published edition likely lives separately with expanded content.
👥Who it's for
Rust learners and computer science students who want to understand DSA fundamentals through concrete, well-organized Rust implementations. Also valuable for Chinese-speaking developers via the dedicated Chinese editions. Contributors helping improve the educational content and code examples.
🌱Maturity & risk
Actively maintained with recent fixes (2024-07-07 README update, 2023 publication edition). The project has a published commercial Chinese edition with 40% more content than the open-source version, indicating solid editorial review. However, no CI/CD pipeline, test framework, or GitHub workflow files are visible in the structure—code quality relies on manual review rather than automated testing.
Low structural risk but moderate quality assurance gaps: no visible test suite (no tests/ or *_test.rs patterns), no CI configuration, and a monorepo with workspace members (main, core, utils) but unclear module boundaries. Single-maintainer appearance (QMHTMY). Positive signal: recent commits and publication indicate active maintenance, but the educational focus means production-critical issues are unlikely to arise.
Active areas of work
Recent maintenance activity: README cleanup (2024-07-07), error fixes (overflow panic handling in 2022-02-09), upgrade to Rust 1.58 (2022-02-02). No open PRs or issues visible in file list. The shift from code/ to publication/code/ (noted in README, 2022-05-15) suggests current development focuses on the publication version.
🚀Get running
git clone https://github.com/QMHTMY/RustBook.git
cd RustBook
cd code/chapter01
rustc rust_basic.rs
./rust_basic
Or use Cargo to run workspace members: cargo run -p main
Daily commands:
Each chapter's .rs files are standalone binaries. Example: rustc code/chapter03/stack.rs && ./stack or cd code/chapter03 && cargo run --example stack if Cargo.toml is configured. The publication/ version likely has proper Cargo manifests; code/ directory is marked as outdated in README.
🗺️Map of the codebase
code/chapter09/blockchain/blockchain1/core/src/blockchain.rs— Core blockchain data structure and validation logic—essential for understanding the capstone project that ties together all prior chapterscode/chapter03/stack.rs— Fundamental stack implementation used as a building block throughout the codebase for recursion, parsing, and algorithm demonstrationscode/chapter07/binary_tree.rs— Binary tree abstraction serves as the foundation for heap, BST, and AVL implementations in later chapterscode/chapter08/graph_adjlist.rs— Graph adjacency list representation—critical for BFS, DFS, and shortest-path algorithms in Chapter 9code/chapter06/quick_sort.rs— Most efficient general-purpose sorting algorithm; demonstrates divide-and-conquer paradigm used throughout the bookREADME.md— Entry point documenting all 10 chapters and linking to outdated vs. current code directories—required orientation for navigating the repocode/chapter09/blockchain/blockchain1/Cargo.toml— Workspace configuration defining module dependencies for the blockchain project that integrates hashing, serialization, and cryptography
🛠️How to make changes
Add a new sorting algorithm
- Create new file in code/chapter06/ following naming convention (e.g., new_sort.rs) (
code/chapter06/new_sort.rs) - Implement sorting function accepting a mutable slice and returning sorted result (
code/chapter06/new_sort.rs) - Add main() with test cases comparing performance to quick_sort.rs and merge_sort.rs (
code/chapter06/new_sort.rs)
Add a new search algorithm
- Create new file in code/chapter05/ (e.g., ternary_search.rs) (
code/chapter05/ternary_search.rs) - Implement search function matching signature of binary_search.rs (
code/chapter05/ternary_search.rs) - Add benchmarks comparing to sequential_search.rs and binary_search.rs (
code/chapter05/ternary_search.rs)
Extend blockchain with new feature
- Edit code/chapter09/blockchain/blockchain1/core/src/block.rs to add fields (e.g., timestamp, nonce) (
code/chapter09/blockchain/blockchain1/core/src/block.rs) - Update code/chapter09/blockchain/blockchain1/core/src/blockchain.rs validation logic (
code/chapter09/blockchain/blockchain1/core/src/blockchain.rs) - Extend code/chapter09/blockchain/blockchain1/utils/src/serializer.rs for new fields (
code/chapter09/blockchain/blockchain1/utils/src/serializer.rs) - Update code/chapter09/blockchain/blockchain1/main/src/main.rs to test new functionality (
code/chapter09/blockchain/blockchain1/main/src/main.rs)
Add a new tree data structure
- Create new file in code/chapter07/ (e.g., red_black_tree.rs) (
code/chapter07/red_black_tree.rs) - Implement Node and Tree structs following bst.rs and avl.rs patterns (
code/chapter07/red_black_tree.rs) - Add insert, delete, and search methods with rebalancing logic (
code/chapter07/red_black_tree.rs) - Add main() with test cases and comparisons to avl.rs performance (
code/chapter07/red_black_tree.rs)
🔧Why these technologies
- Rust — Memory safety without garbage collection; zero-cost abstractions enable teaching DSA with minimal performance overhead; pattern matching and ownership system enforce algorithmic correctness
- Cargo workspace (blockchain1, core, utils, main) — Separates concerns into reusable libraries (core blockchain logic, utilities for hashing) and executable demos; mimics production Rust project structure
- SHA-256 hashing (blockchain) — Industry-standard cryptographic hash for block integrity; demonstrates practical security implications of hash collision theory
⚖️Trade-offs already made
-
Single-file implementations (e.g., stack.rs, quick_sort.rs) rather than separate trait/impl modules
- Why: Maximizes clarity for learning—readers see complete algorithm without abstraction indirection
- Consequence: Code is less modular/reusable than production Rust; duplicated struct definitions across chapters
-
Unsafe blocks avoided in core algorithms
- Why: Maintains Rust's safety guarantees as a teaching goal; shows idiomatic Rust patterns
- Consequence: Some operations (pointer manipulation in linked lists) use safe wrappers (Option<Box<T>>) with slight performance
🪤Traps & gotchas
- The README explicitly states 'the code/ directory is outdated' and 'all demo code is located in publication/code/'—clone publication/ branch or ensure you're reading from the published edition. 2. No visible Cargo.toml in code/chapterXX/ directories in the file list; examples may require manual rustc compilation rather than cargo run. 3. The workspace structure names members as 'main', 'core', 'utils' but their purposes are unclear from the file tree—verify Cargo.toml in those directories. 4. Multiple language editions (CN, TW, EN) mean changes should be coordinated across all README variants to avoid version skew.
🏗️Architecture
💡Concepts to learn
- Tail Recursion — Chapter 5 explicitly teaches tail-recursion optimization; critical for Rust performance since the compiler can eliminate stack growth in recursive algorithms
- Dynamic Programming (Memoization) — Core pattern in chapter 5 (dp_rec.rs, dp_rec_mc.rs files); essential for optimizing recursive solutions and a frequent interview topic
- Big-O Complexity Analysis — Chapter 3 teaches Big-O notation—the foundation for evaluating algorithm efficiency; every DSA example in the book is analyzed with this lens
- Binary Search Trees & AVL Trees — Chapter 8 covers BSTs and AVL trees; self-balancing trees are crucial for real-world systems requiring logarithmic search/insert/delete
- Graph Traversal (BFS/DFS) — Chapter 9 teaches breadth-first and depth-first search; fundamental patterns for pathfinding, cycle detection, and social network analysis
- Consistent Hashing — Chapter 10 covers consistent hashing; essential for distributed systems and load balancing in Rust backends and microservices
- Trie Data Structure — Chapter 10 includes Trie implementation; optimal for prefix searches and autocomplete—common in Rust web frameworks and databases
🔗Related repos
TheAlgorithms/Rust— Comprehensive algorithm collection in Rust covering similar DSA topics but as a flat reference library rather than a structured learning progressionrust-lang/rustlings— Official Rust learning exercises; complements RustBook for foundational language concepts before tackling DSAkrahets/hello-algo— Multi-language DSA textbook (Python, Java, C++, Go, Rust) with interactive visualizations; peer educational resource in similar spaceQMHTMY/RustCode— Likely the publication/ version or a companion repo—check for the expanded 40% content edition mentioned in READMEspacejam/sled— Production Rust database library using advanced DSA patterns (B+ trees, LSM) that practitioners move to after mastering fundamentals in RustBook
🪄PR ideas
To work on one of these in Claude Code or Cursor, paste:
Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.
Add comprehensive unit tests for chapter code examples
The repo contains 50+ algorithm implementations across chapters 1-8 (stack.rs, queue.rs, bst.rs, heap_sort.rs, etc.) but no visible test files. Adding #[cfg(test)] modules with test cases for each data structure and algorithm would validate correctness, prevent regressions, and serve as usage examples for readers.
- [ ] Create test modules in code/chapter03/ for stack.rs, queue.rs, deque.rs, linked_list.rs with basic operation tests
- [ ] Add tests in code/chapter05/ for binary_search.rs, hash.rs, and interpolation_search.rs validating search correctness
- [ ] Add tests in code/chapter06/ for sort algorithms (bubble_sort.rs, quick_sort.rs, merge_sort.rs, heap_sort.rs) with edge cases (empty, single element, duplicates)
- [ ] Add tests in code/chapter07/ for avl.rs, bst.rs, binary_heap.rs, binary_tree.rs validating tree operations
- [ ] Document test execution in README.md with instructions like
rustc --test code/chapter03/stack.rs && ./stack
Complete chapter08 and implement missing chapters 9-10
The file structure shows code/chapter08 exists but is empty, and chapters 9-10 are completely missing. The README promises Graph algorithms (Chapter 9) and Advanced topics like Edit Distance, Trie, LRU (Chapter 10). Implementing these would fulfill the book's promised 10-chapter scope.
- [ ] Create code/chapter08/ directory with binary_tree.rs (if not present), add graph representation implementations (adjacency list, adjacency matrix)
- [ ] Implement code/chapter09/bfs.rs, code/chapter09/dfs.rs, code/chapter09/dijkstra.rs for shortest path algorithms with example usage
- [ ] Implement code/chapter09/graph.rs as the core Graph struct with standard traversal methods
- [ ] Create code/chapter10/ with edit_distance.rs, trie.rs, lru_cache.rs implementations as mentioned in README
- [ ] Add corresponding sections to books/rust-book-en-us-shieber.pdf or create markdown chapters linking to code examples
Set up GitHub Actions CI to compile and test all chapter code
With 50+ Rust files across chapters, there's no visible CI configuration to catch compilation errors or breaking changes. A GitHub Actions workflow would automatically validate that all examples compile cleanly on each push, ensuring the book examples remain accurate.
- [ ] Create .github/workflows/rust-check.yml that runs
cargo checkon the workspace (main, core, utils members) - [ ] Add step to compile each chapter individually:
rustc code/chapter0X/*.rsto catch any broken examples - [ ] Add step to run tests (once implemented via PR #1) using
#[cfg(test)]modules - [ ] Configure workflow to trigger on push to main/master and on pull requests
- [ ] Add status badge to README.md showing build status
🌿Good first issues
- Add unit tests for code/chapter05/binary_search.rs, code/chapter05/hash.rs, and other chapter 5 search algorithms—currently no test/ directory or *_test.rs files visible despite importance for verifying correctness.
- Create a Cargo.toml and build configuration for code/chapter03/ to allow
cargo run --example stackstyle execution instead of manual rustc compilation, improving usability for learners. - Document the workspace member purposes (main/, core/, utils/) in a CONTRIBUTING.md file—current structure is opaque and hinders contributions to the correct module.
⭐Top contributors
Click to expand
Top contributors
- @Shieber — 68 commits
- @QMHTMY — 17 commits
- @NickGhignatti — 1 commits
- @hulufei — 1 commits
📝Recent commits
Click to expand
Recent commits
c2d2d87— fix: fix code error (QMHTMY)936ccde— docs: update (QMHTMY)5414c8c— fix: fix use_weak.rs error (QMHTMY)7179d80— Merge pull request #21 from NickGhignatti/main (QMHTMY)9bec734— refactor: Fix size check in enqueue method (NickGhignatti)63d4355— feat: update (QMHTMY)5961b3d— docs: update README (QMHTMY)e61c10a— feat: update (QMHTMY)145ff37— feat: change info (QMHTMY)011ec7b— docs: update (QMHTMY)
🔒Security observations
This is an educational repository containing Rust data structures and algorithms implementations. The security posture is moderate to good for an educational codebase. No critical vulnerabilities are immediately apparent from the file structure analysis. Main recommendations: (1) Provide complete Cargo.toml content for dependency analysis using 'cargo audit', (2) Document that examples are for learning purposes only and require security review before production use, (3) Implement standard repository security practices (SECURITY.md, .gitignore, dependency scanning), and (4) Add input validation and error handling guidance to algorithm examples, particularly for the blockchain implementation. The codebase appears well-organized and focused on educational content rather than production systems.
- Low · Incomplete Dependency Information —
code/chapter09/blockchain/blockchain1/Cargo.toml (workspace). The provided Cargo.toml workspace file shows only member references without explicit dependency version specifications. While this is not inherently a vulnerability, it makes it impossible to verify if pinned versions are used or if vulnerable dependencies are included. The actual dependency declarations in individual member Cargo.toml files are not provided for analysis. Fix: Ensure all dependencies in individual member Cargo.toml files use exact versions or verified version ranges. Regularly run 'cargo audit' to check for known vulnerabilities in dependencies. Consider using a lock file (Cargo.lock) in version control. - Low · No Security Configuration Files Detected —
Repository root. No evidence of security-related configuration files such as .env (with secrets management), security policy documentation, or dependency audit tooling configuration files are present in the repository structure. Fix: Add .env.example (without secrets), implement environment variable management, create SECURITY.md for vulnerability reporting, and configure automated dependency scanning tools. - Low · Educational Code Without Security Warnings —
code/chapter09/blockchain/ and other algorithm implementations. This repository contains educational code examples for data structures and algorithms. While the code appears to be demonstration-focused, some files (particularly in blockchain and graph implementations) could potentially contain unsafe patterns or unvalidated inputs if used in production without proper security review. Fix: Add prominent documentation that these are educational examples and should not be used directly in production without security review. Include input validation and error handling best practices in examples. - Informational · Missing .gitignore and .env File Protection —
Repository root. No .gitignore file was noted in the provided file structure. Educational repositories should still protect against accidental commits of configuration files or build artifacts. Fix: Create a comprehensive .gitignore file that excludes: target/, Cargo.lock (if not committing), .env files, IDE-specific directories, and OS-specific files.
LLM-derived; treat as a starting point, not a security audit.
👉Where to read next
- Open issues — current backlog
- Recent PRs — what's actively shipping
- Source on GitHub
Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.