Loading repository data…
Loading repository data…
zeybek / repository
Rust for TypeScript & JavaScript developers — a free, open-source guide that teaches Rust by mapping every concept to the TS/JS you already know.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A comprehensive, hands-on guide to learning Rust for developers coming from TypeScript or JavaScript. It uses side-by-side code comparisons so you can leverage what you already know while learning what makes Rust different.
📖 This guide is published as a website built with Astro Starlight — searchable, with a chapter sidebar, "Edit on GitHub" links, and TypeScript↔Rust syntax highlighting.
Live site: rs4ts.dev • Or read it offline: run locally with the two commands below, or browse the Markdown under
src/content/docs/.
npm install # Node 22.12+ (see .nvmrc)
npm run dev # open http://localhost:4321
Prerequisites: Solid TypeScript/JavaScript, familiarity with npm/package managers, basic programming concepts. No Rust knowledge required.
// TypeScript — safe under a strict configuration after boundary validation
interface Item { value: number }
function processData(data: readonly Item[]): number[] {
return data.map((item) => item.value * 2);
}
// Rust — compile-time safety, zero-cost abstractions, no GC pauses
struct Item { value: i32 }
fn process_data(data: &[Item]) -> Vec<i32> {
data.iter().map(|item| item.value * 2).collect()
// Safe Rust prevents null dereferences, use-after-free, and data races
}
Rust offers:
The guide is 31 chapters (00–30). Each is a folder under src/content/docs/; the links below open each chapter's intro. For the full navigable, searchable experience, read the website (or npm run dev).
?Each concept topic (chapters 01–29) follows a fixed 10-part format:
Note: The orientation pages in Chapter 00 and the build-along capstone projects in Chapter 30 use a format tailored to their purpose, so they don't carry every part above.
Suggested paths: 🏃 Quick (70–85h): orientation, then 01–05, 08, 11, 16 · 🚶 Standard (180–230h): 00–19, skim 20–26, build two projects · 🎓 Complete (300–400h): all 31 chapters + six projects. These ranges include the reading, practice, and exercise estimates published by the chapters; your pace will vary.
rs4ts/
├─ src/content/docs/ # the 31 chapters (Markdown) — the site content
│ ├─ index.mdx # landing page
│ └─ NN-section/ # each chapter: index.md + NN-topic.md pages
├─ examples/ # 6 runnable Rust capstone crates
│ ├─ rest-api-code/ cli-tool-code/ microservice-code/
│ └─ websocket-chat-code/ wasm-app-code/ full-stack-code/
├─ astro.config.mjs # Starlight config (sidebar, fonts, theme)
├─ src/content.config.ts # content collection schema
├─ src/styles/custom.css # brand (IBM Plex, Rust-orange accent)
└─ public/ # favicon, robots.txt
npm install # Node 22.12+ (nvm: `nvm use`)
npm run dev # dev server at http://localhost:4321
npm run build # production build into dist/
npm run preview # preview the production build
Each crate under examples/ is a standalone Rust project:
cd examples/rest-api-code
cargo run # (wasm-app-code targets wasm32 — see its README)
| Concept | TypeScript/JavaScript | Rust |
|---|---|---|
| Memory Management | Garbage collection | Ownership system (compile-time) |
| Null Safety | Union types checked with strictNullChecks | Option<T>; ordinary references non-null |
| Error Handling | Exceptions; result unions/libraries by choice | Result<T, E>; panics still exist |
| Mutability | Reassignable bindings and mutable objects | Immutable bindings by default; mut explicit |
| Type System | Structural, erased; strictness configurable | Mostly nominal, compiled and mandatory |
| Concurrency | Event loop plus Web/Node worker threads | OS threads plus optional async runtimes |
| Runtime | JavaScript VM/runtime (V8, Node.js, Deno) | Native binary; no VM or garbage collector |
| Package Manager | npm, yarn, pnpm | Cargo (built-in) |
| Interfaces | interface, type aliases | traits |
| Async | eager Promise, async/await | lazy Future, async/await |
| Runtime Speed | JIT; workload-dependent | AOT; workload-dependent |
| Learning Curve | Moderate | Steep (ownership is new) |
// TypeScript — shared references, GC cleans up
let data = { value: 42 };
let data2 = data; // both reference the same object
console.log(data.value); // 42 — still accessible
// Rust — ownership moved, tracked at compile time
let data = String::from("hello");
let data2 = data; // ownership moved to data2
// println!("{}", data); // ❌ compile error: data no longer valid
println!("{}", data2); // ✅ data2 owns it
This compile-time tracking prevents use-after-free, double-free, data races, and null-pointer dereferences — without a garbage collector.
You only need Rust to run the example crates; the guide itself reads in the browser.
# Install Rust (includes Cargo)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustc --version && cargo --version
Found an error, typo, or have a suggestion? Contributions are welcome — see CONTRIBUTING.md. Every page has an Edit on GitHub link on the site. Starring the repo ⭐ helps others find it.
All 31 chapters (00–30) are complete. The six capstone crates are locked and checked in CI with the repository's pinned Rust toolchain: formatting, Clippy, native tests, and wasm32-unknown-unknown checks where relevant. A deterministic subset of self-contained standard-library page programs is also compiled by the documentation snippet check; fragments, exercises, external-dependency examples, and intentionally non-compiling snippets are excluded explicitly. See the version and verification policy for the exact scope.
The guide is 330 Markdown pages across the 31 chapters, plus 6 runnable example crates.
Licensed under the MIT License.