Skip to content

DarKWinGTM/learn-rust-from-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learn Rust From Python

การเรียน Rust สำหรับคนที่รู้ Python — เปรียบเทียบ Python ↔ Rust แบบเข้าใจง่าย

Rust License

📚 เกี่ยวกับชุดเอกสารนี้

ชุดเอกสารนี้ออกแบบมาเพื่อ สอน Rust สำหรับคนที่รู้ Python โดยเปรียบเทียบ Python ↔ Rust แบบเข้าใจง่าย เน้นการเรียนรู้ที่ นำไปใช้ได้จริง และเข้าใจ mental model ของ Rust ไม่ใช่แค่ syntax

🎯 เป้าหมายการเรียนรู้

หลังจากอ่านชุดเอกสารนี้ คุณจะสามารถ:

  • ✅ ออกแบบโปรแกรมแบบ Rust ได้: owner/borrow/error path ชัด
  • ✅ อ่าน compiler error แล้วแก้ได้เป็นขั้นตอน (ไม่เดา)
  • ✅ แปลง data model จาก dict/list ไปเป็น struct/Vec/HashMap แบบไม่ปวด
  • ✅ วางโครงโปรเจกต์ + workflow ให้ทำงานจริงได้ (cargo check/fmt/clippy/test)

📖 เนื้อหา (19 บท)

พื้นฐาน (Mode A - ปูพื้น)

  1. Start Basic — setup, hello world, variables, ownership intro, Option/Result
  2. Ownership & Borrowing — แกนที่ทำให้ Rust แตกต่าง
  3. Error Handling — Option/Result, ?, error types
  4. Collections & Data Modeling — dict/list → HashMap/Vec/struct

โครงสร้างโปรเจกต์ (Mode B - ทำงานจริง)

  1. Modules & Project Structure — monolith → mod/crate
  2. Tooling & Workflow — cargo, fmt, clippy, test
  3. Config & Serde JSON — อ่าน JSON แบบค่อย ๆ tighten schema
  4. CLI Basics — ทำ CLI แบบ Rust: parse → command enum → execute

ขั้นสูง

  1. Shared State & Concurrency — Arc/Mutex/RwLock
  2. Logging Design — log pipeline ที่แยก concerns
  3. Mini Projects — mini exercises ที่ปลอดภัย
  4. Learning Playbook — playbook การเรียนต่อ

พิเศษ

  1. Lifetimes Practical — lifetimes แบบใช้จริง
  2. Traits & Generics — duck typing → trait bounds
  3. Iterators & Closures — map/filter/collect
  4. Testing & Debugging — test structure, assert
  5. Serde Advanced — serde ขั้นสูง
  6. Rust Macros — macros แบบเข้าใจง่าย
  7. Production Hygiene — production: deps/secrets/config/logs

🚀 วิธีใช้เอกสาร

อ่านตามลำดับเลขไฟล์ (00 → 19)

จะต่อเนื่องที่สุด เพราะบทถูกเรียงตาม "ลำดับที่สมองคนมาจาก Python มักสะดุด"

อ่านแบบมีเป้าหมาย (3 โหมด)

โหมด A: ปูพื้นให้เขียน Rust ได้เร็ว (แนะนำสำหรับมือใหม่)

01 → 02 → 03 → 04

โหมด B: ทำงานจริงแบบโปรเจกต์เล็ก (เน้นใช้งาน)

05 → 06 → 10 → 09

โหมด C: สะสมทักษะต่อเนื่อง (แก้ตอนสะดุด)

12 — เปิดทันทีเมื่อเจอ borrow checker/compile error
11 — ฝึกแบบ "หนึ่งโปรเจกต์ = หนึ่ง crate"

💡 สิ่งที่ทำให้ชุดเอกสารนี้แตกต่าง

  • ✍️ เขียนเป็นภาษาไทย — เข้าใจง่ายกว่าอ่านภาษาอังกฤษ
  • 🔄 เปรียบเทียบ Python ↔ Rust — ช่วยให้เข้าใจ mental model ของ Rust
  • 📊 มีตัวอย่างโค้ดจริง — ไม่ใช่แค่ทฤษฎี
  • 🎯 นำไปใช้ได้จริง — เน้น pattern ที่ใช้ใน production
  • 🔧 เจาะจง — เลี่ยงไปทางที่คน Python มักสะดุด

🛠️ เครื่องมือที่ต้องการ

# ติดตั้ง Rust toolchain
rustc --version
cargo --version

# สร้างโปรเจกต์แรก
cargo new hello_rust
cd hello_rust
cargo run

เครื่องมือแนะนำ:

  • rust-analyzer — IDE extension (VS Code / IntelliJ IDEA)
  • cargo — build/test/dependency manager
  • cargo check — เช็คโค้ดเร็วโดยไม่ build

📖 อ้างอิง

📝 License

MIT License — อนุญาตให้ใช้ได้ทั้งเชิงพาณิชย์และส่วนตัว

🤝 การมีส่วนร่วม

ถ้าต้องการมีส่วนร่วม หรือพบข้อผิดพลาด สามารถ:

  • Open issue
  • Pull request
  • ติดต่อผ่านทาง GitHub

สนุกกับการเรียน Rust! 🦀

About

Learn Rust from Python - Complete Thai documentation with Python ↔ Rust comparisons

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •