ต้นแบบ · รุ่นทดลอง: มีทุก server ในทะเบียนทางการ อัปเดตทุก 30 นาที เข้าสู่ระบบด้วย Google เพื่อเขียนรีวิวได้แล้วต้นแบบ · อัปเดตทุก 30 นาที
PopNx MCPที่รวม MCP สำหรับคนใช้ AI · วิธีติดตั้งภาษาไทยทุกตัว

BeautifulRust Skill

โดย morganlinton★ 1,8261 skill

ติดตั้ง

ใช้ทำอะไรได้

ยังไม่มีคำอธิบายภาษาไทย ดูข้อเท็จจริงด้านล่าง หรือเปิดคำอธิบายต้นฉบับจากผู้ทำ

  • ต่อแบบ ไฟล์คำสั่งให้ AI อ่าน ไม่ต่อบริการใด
  • บัญชีหรือคีย์ ไม่ต้องใส่คีย์
  • หมวด เขียนโค้ด
คำอธิบายต้นฉบับจากผู้ทำ (อังกฤษ)
Agent Skills that teach coding agents to write, review, and port idiomatic Rust, plus a tested clippy config. Works with Claude Code, Codex, Copilot, Cursor, and Gemini CLI.
สำหรับผู้ทำ: ติดป้ายใน README

ถ้าคุณเป็นผู้ทำตัวนี้ คัดลอกโค้ดนี้ไปวางใน README ได้เลย ป้ายลิงก์กลับมาที่หน้านี้

[![แนะนำบน PopNx MCP](https://mcp.popnx.com/badge/skill/morganlinton-beautifulrust.svg?lang=th)](https://mcp.popnx.com/th/skills/morganlinton-beautifulrust)

ใช้คู่กับ

MCP ที่ต่อ AI เข้ากับบริการในงานเดียวกัน

REA

แกะการทำงานของโปรแกรมและแอปจากเทอร์มินัลหรือจาก AI

โดย morlutoใช้กันมาก↓ 388.7K/สัปดาห์★ 461.8Kอัปเดต 4 วันที่ผ่านมา

MCP · ต่อบริการรันบนเครื่อง

Fallow

Codebase intelligence for TypeScript and JavaScript, exposed as structured MCP analysis tools.

โดย fallow-rsใช้กันมาก↓ 2.4M/สัปดาห์★ 5.4Kอัปเดต เมื่อวาน

MCP · ต่อบริการรันบนเครื่อง

Desktop Commander

MCP server for terminal commands, file operations, and process management

โดย wonderwhy-erใช้กันมาก↓ 740.3K/สัปดาห์★ 10.3Kอัปเดต 4 วันที่ผ่านมา

MCP · ต่อบริการรันบนเครื่อง

Skill ที่ทำงานคล้ายกัน

หมวดงานเดียวกัน เรียงแบบเดียวกับหน้ารายการ Skill

เทียบกับตัวที่คล้ายกัน
ตัวนี้
BeautifulRust
reagraphifyarchifysecurity-audit-skill
ผู้ทำmorganlintonmorlutoGraphify-Labstt-a1icloudflare
จำนวน Skill11111
ดาว GitHub1,826461,751148,35296,75773,156
แก้โค้ดล่าสุด9 พ.ย. 256916 พ.ย. 256916 พ.ย. 256915 พ.ย. 256915 ก.ย. 2569
สัญญาอนุญาตMITMITApache-2.0Apache-2.0MIT

ชุดคำสั่ง (Skill) 1 ชุดจาก morganlinton ให้ AI อ่านแล้วทำงานตามวิธีนี้ · ไม่ใช่ MCP server

Skill ต่างจาก MCP ยังไง

MCP = มือ

ต่อ AI เข้ากับบริการหรือข้อมูลข้างนอก เช่น อ่าน Notion หรือสร้างใบแจ้งหนี้ ต้องมีโปรแกรมหรือ server ทำงานอยู่

Skill = คู่มือ

ไฟล์ข้อความที่สอน AI ว่างานนี้ทำยังไง ไม่ต่อบริการใด

บางตัวคล้ายกัน: Skill บางตัวมีสคริปต์เรียกเครื่องมือ และ MCP บางตัวส่งแค่ความรู้ ให้ดูที่งานที่อยากทำเป็นหลัก

ใช้กับแอปไหน

Claude CodeClaude (เว็บ/แอป)CodexCursorGemini CLIGitHub Copilot

ตามที่ README ของผู้ทำเขียนไว้ และโฟลเดอร์ที่มีใน repo

ติดตั้ง

ปลอดภัยไหม

  • ใครทำ

    บัญชี GitHub morganlinton (บุคคล) เปิดมา 8 ปี

  • คนใช้และการดูแล

    ★ 1,826 ดาว · แก้โค้ดล่าสุด 9 พ.ย. 2569

  • มีสคริปต์ไหม

    มีสคริปต์ 5 ไฟล์ที่รันบนเครื่องได้: evals/bevy-arena-regen/place-files.sh, evals/refactor-inventory-module/place-files.sh, evals/bevy-arena-regen/files/src/lib.rs, evals/bevy-arena-regen/files/tests/arena.rs และอีก 1 ไฟล์

  • ใช้อินเทอร์เน็ตไหม

    ไม่พบคำสั่งเรียกอินเทอร์เน็ตในสคริปต์

  • แก้ค่าตั้งทั้งเครื่องไหม

    ไม่พบ hook หรือการเขียนค่าตั้งของเครื่อง

ตรวจอัตโนมัติจากไฟล์ใน repo ที่ commit b971843 (อ่านไฟล์อย่างเดียว ไม่ได้รัน) ไม่ใช่การรับรองความปลอดภัย อ่านแล้วตัดสินใจเอง

ขั้นแรก: คุณใช้ AI ตัวไหน

เลือกแอปที่ใช้ แล้วหน้านี้จะแสดงเฉพาะวิธีติดตั้งของแอปนั้น

ทางที่ 1อัปโหลดเข้า claude.ai (เว็บและแอป)

อัปโหลดใน claude.ai ไม่ผ่าน เพราะคำอธิบายยาวเกิน 200 ตัวอักษร (593 ตัวอักษร) ใช้ทาง "ให้ AI ติดตั้งให้" แทน

ทางที่ 1ให้ Claude Code ติดตั้งให้

คัดลอกประโยคนี้ไปวางในแชตของ Claude Code

ติดตั้งไว้ที่ไหน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

เลือกเฉพาะโปรเจกต์ ให้วางในแชตที่เปิดอยู่ในโฟลเดอร์ของโปรเจกต์นั้น · AI จะบอก path ให้ดูก่อนติดตั้งเสมอ

AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น

เปิด Claude Code ใหม่ แล้วพิมพ์ /rust-best-practices หรือสั่งงานที่ตรงเรื่อง Claude จะเลือกใช้เอง

ตรวจกับเอกสารทางการล่าสุด 12 พ.ย. 2569 · แหล่ง: code.claude.com

สำหรับคนที่ใช้ Terminal

Skill คือคำสั่งที่ AI จะทำตาม อ่านไฟล์ก่อนติดตั้ง และติดตั้งเฉพาะจากผู้ทำที่เชื่อถือได้

วิธีที่ผู้ทำแนะนำ

ลง Node.js ในเครื่อง (ถ้ายังไม่มี)

ลงไว้แล้วหรือยัง? เช็กก่อน · เปิด Terminal แล้วพิมพ์คำสั่งนี้ กด Enter

node -v
  • ขึ้นเลขรุ่น เช่น v26.13.1 = ลงแล้ว ข้ามขั้นนี้ได้
  • ขึ้นว่า "command not found" (Windows ขึ้นว่า "is not recognized") = ยังไม่ได้ลง หรือเพิ่งลงแต่ยังไม่ได้ปิดแล้วเปิด Terminal ใหม่
เปิด Terminal ยังไง

Mac: กด ⌘ + Space พิมพ์ Terminal แล้วกด Enter

Windows: เปิดเมนู Start พิมพ์ Windows PowerShell แล้วกด Open

ยังไม่ได้ลง: เปิดหน้าดาวน์โหลดทางการ เลือกรุ่น LTS แล้วเลือกตัวติดตั้งแบบกดเอง: Mac ไฟล์ .pkg · Windows ไฟล์ .msi ดับเบิลคลิกแล้วกดถัดไปจนจบ ไม่ต้องใช้คำสั่ง curl

เปิดหน้าดาวน์โหลด Node.js ↗

ลงเสร็จแล้ว ปิด Terminal เปิดใหม่ แล้วพิมพ์คำสั่งเดิมอีกครั้ง ต้องขึ้นเลขรุ่น: node -v

ลงครั้งเดียว ใช้ได้กับทุกตัวที่ต้องใช้ Node.js

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

คำสั่งนี้คัดมาจาก README ของผู้ทำ จะดาวน์โหลดและรันโค้ดของผู้ทำ

  1. เปิด Terminal

    Mac: กด Command+Space พิมพ์ Terminal · Windows: คำสั่งด้านล่างใช้ใน PowerShell ไม่ได้ ให้ใช้ทาง “ให้ AI ติดตั้งให้” ด้านบนแทน

  2. คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.claude/skills

    คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md

    กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

  3. เปิด Claude Code ใหม่ แล้วพิมพ์ /rust-best-practices หรือสั่งงานที่ตรงเรื่อง Claude จะเลือกใช้เอง

Skill ที่ติดตั้งเองใช้ได้ในแอป ChatGPT บนคอม, Codex CLI และส่วนขยาย Codex ใน IDE · ChatGPT บนเว็บและมือถือใช้ Skill ที่ติดตั้งเองไม่ได้ ใช้ได้เฉพาะ Skill ที่มากับปลั๊กอินในไดเรกทอรี

แอป ChatGPT บนคอม

แอป ChatGPT บนคอมมี Codex อยู่ในตัว Codex อ่าน Skill จากโฟลเดอร์ ~/.agents/skills

ทางที่ 1ให้ ChatGPT ติดตั้งให้

เปิด Codex ในแอป ChatGPT บนคอม แล้ววางประโยคนี้ในแชต

ติดตั้งไว้ที่ไหน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

AI จะบอก path ให้ดูก่อนติดตั้งเสมอ

AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น

ทางที่ 2วางโฟลเดอร์เอง

วางโฟลเดอร์ rust-best-practices ไว้ที่ ~/.agents/skills/rust-best-practices

~ คือโฟลเดอร์บ้านของคุณ ($HOME)

สำหรับคนที่ใช้ Terminal

Skill คือคำสั่งที่ AI จะทำตาม อ่านไฟล์ก่อนติดตั้ง และติดตั้งเฉพาะจากผู้ทำที่เชื่อถือได้

  1. เปิด Terminal

    Mac: กด Command+Space พิมพ์ Terminal · Windows: คำสั่งด้านล่างใช้ใน PowerShell ไม่ได้ ให้ใช้ทาง “ให้ AI ติดตั้งให้” ด้านบนแทน

  2. คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.agents/skills

    คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md

    กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

หลังติดตั้ง

  • แอป ChatGPT บนคอม: เปิด Skills ในแถบข้างเพื่อดูว่า Skill ขึ้นแล้ว
  • เรียกใช้: ใน ChatGPT พิมพ์ @ แล้วเลือก Skill · ใน Codex CLI หรือส่วนขยายใน IDE พิมพ์ /skills หรือพิมพ์ $ แล้วตามด้วยชื่อ Skill
  • Codex เห็น Skill ที่ติดตั้งใหม่เอง ถ้ายังไม่ขึ้นให้ปิดแล้วเปิด Codex ใหม่

ตรวจกับเอกสารทางการล่าสุด 15 พ.ย. 2569 · แหล่ง: learn.chatgpt.com

ChatGPT บนเว็บและมือถือ

ใช้ Skill ที่ติดตั้งเองไม่ได้ ใช้ได้เฉพาะ Skill ที่มากับปลั๊กอินในไดเรกทอรี

อยากใช้ Skill นี้กับ ChatGPT ให้ใช้แอป ChatGPT บนคอมตามวิธีด้านบน

ตรวจกับเอกสารทางการล่าสุด 15 พ.ย. 2569 · แหล่ง: learn.chatgpt.com

ทางที่ 1ให้ Codex ติดตั้งให้

คัดลอกประโยคนี้ไปวางในแชตของ Codex · ใช้ได้ทั้ง Codex ในแอป ChatGPT บนคอม, Codex CLI และส่วนขยายใน IDE

ติดตั้งไว้ที่ไหน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

เลือกเฉพาะโปรเจกต์ ให้วางในแชตที่เปิดอยู่ในโฟลเดอร์ของโปรเจกต์นั้น · AI จะบอก path ให้ดูก่อนติดตั้งเสมอ

AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น

Codex เห็น Skill ที่ติดตั้งใหม่เอง ถ้ายังไม่ขึ้นให้ปิดแล้วเปิด Codex ใหม่ · เรียกใช้: ใน ChatGPT พิมพ์ @ แล้วเลือก Skill · ใน Codex CLI หรือส่วนขยายใน IDE พิมพ์ /skills หรือพิมพ์ $ แล้วตามด้วยชื่อ Skill

ตรวจกับเอกสารทางการล่าสุด 15 พ.ย. 2569 · แหล่ง: learn.chatgpt.com

สำหรับคนที่ใช้ Terminal

Skill คือคำสั่งที่ AI จะทำตาม อ่านไฟล์ก่อนติดตั้ง และติดตั้งเฉพาะจากผู้ทำที่เชื่อถือได้

  1. เปิด Terminal

    Mac: กด Command+Space พิมพ์ Terminal · Windows: คำสั่งด้านล่างใช้ใน PowerShell ไม่ได้ ให้ใช้ทาง “ให้ AI ติดตั้งให้” ด้านบนแทน

  2. คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.agents/skills

    คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md

    กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

  3. เปิด Codex ใหม่ แล้วสั่งงานที่ตรงเรื่อง Codex จะเห็น skill นี้ในรายการ

ทางที่ 1ให้ Cursor ติดตั้งให้

คัดลอกประโยคนี้ไปวางในแชตของ Cursor

ติดตั้งไว้ที่ไหน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

เลือกเฉพาะโปรเจกต์ ให้วางในแชตที่เปิดอยู่ในโฟลเดอร์ของโปรเจกต์นั้น · AI จะบอก path ให้ดูก่อนติดตั้งเสมอ

AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น

ใน Agent chat ของ Cursor พิมพ์ / แล้วเลือก rust-best-practices

ตรวจกับเอกสารทางการล่าสุด 12 พ.ย. 2569 · แหล่ง: cursor.com

สำหรับคนที่ใช้ Terminal

Skill คือคำสั่งที่ AI จะทำตาม อ่านไฟล์ก่อนติดตั้ง และติดตั้งเฉพาะจากผู้ทำที่เชื่อถือได้

  1. เปิด Terminal

    Mac: กด Command+Space พิมพ์ Terminal · Windows: คำสั่งด้านล่างใช้ใน PowerShell ไม่ได้ ให้ใช้ทาง “ให้ AI ติดตั้งให้” ด้านบนแทน

  2. คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.cursor/skills

    คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md

    กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

  3. ใน Agent chat ของ Cursor พิมพ์ / แล้วเลือก rust-best-practices

ทางที่ 1ให้ AI ติดตั้งให้

สำหรับแอปอื่นที่อ่าน Skill ได้ ประโยคนี้มี path ของ Claude Code, Codex และ Cursor ให้ AI เลือกตามแอปที่ใช้ · คัดลอกประโยคนี้ไปวางในแชตของแอป

ติดตั้งไว้ที่ไหน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

กำลังตรวจคำสั่ง · ปุ่มคัดลอกจะขึ้นเมื่อตรวจผ่าน

เลือกเฉพาะโปรเจกต์ ให้วางในแชตที่เปิดอยู่ในโฟลเดอร์ของโปรเจกต์นั้น · AI จะบอก path ให้ดูก่อนติดตั้งเสมอ

AI จะบอกก่อนว่าจะทำอะไร และขออนุญาตคุณทุกขั้น

ตรวจกับเอกสารทางการล่าสุด 12 พ.ย. 2569 · แหล่ง: code.claude.com, learn.chatgpt.com, cursor.com

สำหรับคนที่ใช้ Terminal

แอปอื่นที่รองรับ Agent Skills (เช่น Gemini CLI, GitHub Copilot) เก็บ skill ในโฟลเดอร์ต่างกัน ดูคู่มือของแอปนั้น แล้วคัดลอกโฟลเดอร์ที่มี SKILL.md ไปวาง

ดูบน GitHub ↗

ตรวจโฟลเดอร์ skill กับคู่มือทางการของ Claude Code, Codex และ Cursor เมื่อ 11 พ.ย. 2569

ดูไฟล์ต้นฉบับ SKILL.md

ข้อความต่อไปนี้มาจาก repo ของผู้ทำ ไม่ใช่คำสั่งของ PopNx MCP

แสดง 8,000 ตัวอักษรแรก · เปิดไฟล์เต็มบน GitHub

---
name: rust-best-practices
description: >-
  Write idiomatic, robust, maintainable Rust. Use this skill whenever you write, review,
  refactor, debug, or explain Rust code: new crates, modules, functions, structs, traits,
  error types, async code, unsafe or FFI code, Cargo.toml, tests, or rustdoc. Trigger on
  any mention of Rust, cargo, crates, .rs files, the borrow checker, lifetimes, traits,
  clippy, or rustfmt, even when the user does not ask for "best practices" or "idiomatic"
  code. Synthesized from the Google Rust Style Guide, the Rust API Guidelines,
  Effective Rust, Rust Design Patterns, and Microsoft's Pragmatic Rust Guidelines.
---

# Rust best practices

Distilled from five Rust style and design guides, with a digest of each in `references/`.
Where they disagree, this file says which to follow and why.

## 1. Mindset

- **Write Rust-shaped code.** Don't port C++, Java, C#, or Python constructs one-to-one.
  Model errors with `Result`, resources with ownership and `Drop`, polymorphism with
  traits and enums, and nullability with `Option`. Inheritance-flavored tricks (`Deref` to
  a "base" struct, `Manager`/`Factory` types, `throw_if_null` helpers) are smells.
- **Make invalid states unrepresentable.** Push invariants into types: enums instead of
  bool flags and "must be X if Y" comments, newtypes for units and IDs, fallible
  constructors that validate once. Then the compiler enforces what a comment only requests.
- **Application code is not library code.** Library code (anything with external users)
  follows the API-design rules below strictly. Application code should favor simplicity
  and directness: concrete types, `String` or `&str` rather than `impl Into<String>`
  parameters, `anyhow`-style errors, `Vec` return values, no speculative generality.
- **Let the tools do the work.** rustfmt owns formatting, clippy owns idiom checks, the
  compiler owns memory safety. Spend your attention on design.

## 2. Before you hand back code

Run these and fix everything they report:

```bash
cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
cargo test
cargo doc --no-deps   # libraries: catches broken doc links and missing docs
```

- Fix a lint rather than silencing it. When a lint is genuinely wrong for one item, use
  `#[expect(clippy::name, reason = "...")]` on the narrowest item. `expect` warns when
  the lint stops firing, so stale suppressions get cleaned up. Use `#[allow]` only in
  generated code or macro output.
- Never put `#![deny(warnings)]` in source: new toolchains add warnings and break the
  build. Enforce warnings-as-errors in CI instead, with `cargo clippy -- -D warnings`.
- Configure lints once in `Cargo.toml` (`[lints]` or `[workspace.lints]`), not with
  scattered crate attributes. If a project has none, suggest `lints/lints.toml` and
  `lints/clippy.toml` from https://github.com/morganlinton/BeautifulRust; the suppression
  lints in it need `rust-version` 1.81 or later.

## 3. Ownership and borrowing

**Prefer unique ownership.** Reach for `Rc`/`Arc` only when shared ownership is part of
the design, and for `RefCell`/`Mutex` only when interior mutability is. They are not
failures, but they move checking from compile time to run time, so use them on purpose.

**Don't clone to make the borrow checker stop complaining.** A clone that exists only to
end a borrow produces a silent copy whose later changes are lost. Try these first, in
roughly this order:

1. Extend a temporary with a named `let`, or shorten a borrow with a block.
2. Split a long expression into typed intermediates so the failing step is visible.
3. Move a field out of `&mut self` with `std::mem::take` (needs `Default`),
   `std::mem::replace`, or `Option::take` instead of cloning it.
4. Split a large struct into smaller ones so disjoint fields can be borrowed separately.
   The compiler tracks disjoint field borrows inside one function, but not across
   method calls.
5. Clone small, immutable data deliberately, and say so in a comment if it's not obvious.
6. Use indices into an owning `Vec`, or `Rc<RefCell<_>>` with `Weak` back-pointers, as
   a last resort. Avoid self-referential structs.

```rust
// Move out of a &mut enum without cloning.
fn a_to_b(e: &mut MyEnum) {
    if let MyEnum::A { name, x: 0 } = e {
        *e = MyEnum::B { name: std::mem::take(name) };
    }
}
```

**Accept the most general borrowed type.** `&str` not `&String`, `&[T]` not `&Vec<T>`,
`&T` not `&Box<T>`, `Option<&T>` not `&Option<T>`. Deref coercion then lets callers pass
owned values, borrows, or literals. Where you only read a path, string, or byte buffer,
`impl AsRef<Path>` / `impl AsRef<str>` / `impl AsRef<[u8]>` is fine on parameters (never
on struct fields; store `PathBuf` and `String`). Library code that only iterates should
take `impl IntoIterator<Item = T>`; application code may simply take `&[T]`.

**Take ownership only when you need it, and then take it by value.** If a function stores
or consumes its argument, take `T`, not `&T` plus an internal `.clone()`. If it only
reads, take `&T`; if it mutates in place, `&mut T`. Return multiple values as a tuple or
struct, not through `&mut` out-parameters (reusing a caller-owned buffer, as
`Read::read` does, is the exception).

**Prefer owned data in structs.** A struct holding `&'a T` forces a lifetime onto every
container. Owning a `String` or `Vec<u8>` is usually simpler and rarely the bottleneck.
When a type does carry a lifetime, give it a descriptive name (`'src`, `'conn`); `'_` and
`'a` are fine on simple functions.

**Freeze after setup.** Build with `let mut`, then rebind `let data = data;` so later
code cannot mutate it by accident.

**Keep `Rc`, `Arc`, `Box`, and `RefCell` out of public signatures.** Take `&T`,
`&mut T`, or `T` and let callers decide how to own things. A service that must be shared
implements a cheap `Clone` by wrapping its state in `Arc<Inner>` internally.

## 4. Types and API design

### Naming

| Item | Case | Notes |
|---|---|---|
| Types, traits, enum variants | `UpperCamelCase` | Acronyms are one word: `Uuid`, `HttpClient` |
| Functions, methods, modules, locals | `snake_case` | |
| Constants, statics | `SCREAMING_SNAKE_CASE` | |
| Type parameters | short, from the main bound | `T`, `R: Read`, `W: Write` |
| Lifetimes | short lowercase | descriptive when on a type |

- No `get_` prefix on getters: `fn len(&self)`, `fn name(&self) -> &str`,
  `fn name_mut(&mut self)`. Use bare `get` only when there is one obvious thing to get
  (`Cell::get`). Related: `set_foo(T)`, `take_foo()`, `with_foo(|f| ..)` for closure
  access, and unsafe `_unchecked` siblings for checked accessors.
- Conversion prefixes signal cost and ownership: `as_` (free, borrow to borrow), `to_`
  (expensive, borrow to owned or borrow to borrow), `into_` (consumes `self`). Put `mut`
  in type order: `as_mut_slice`, not `as_slice_mut`.
- Constructors: `new` (primary), `with_capacity` / `new_with_foo` (variants), `try_new`
  (fallible), `from_foo` (conversion; pair important ones with a `From` impl). I/O
  resources use domain verbs: `File::open`, `TcpStream::connect`.
- `iter` / `iter_mut` / `into_iter` return types named `Iter` / `IterMut` / `IntoIter`;
  `keys()` returns `Keys`.
- Error types read verb-object-error: `ParseBoolError`, not `BoolParseError`.
- Avoid weasel suffixes `Service`, `Manager`, `Factory`, `Helper`, `Util`. Name the thing
  it is (`Bookings`, `Dispatcher`, `FooBuilder`). Don't repeat the module name in the
  type (`foo::Id`, not `foo::FooId`). Avoid abbreviations an outsider wouldn't know.
- If you implement `len()`, implement `is_empty()`.
- Feature names are bare: `std`, `serde`, `alloc`, never `use-std` or `no-std`.

### Model the domain with types

- **Newtypes** for semantic distinctions: `struct Miles(f64)` and `struct Kilometers(f64)`
  cannot be mixed, where a type alias can. Add `#[repr(transparent)]` when layout matters,
  and derive or forward the traits you need (`derive_mo

พูดคุย

ถาม แชร์เคล็ดลับ หรือแจ้งว่าใช้ไม่ได้ เรียงตามที่คนกดว่ามีประโยชน์

ยังไม่มีใครโพสต์ ถามหรือแชร์เป็นคนแรกได้เลย

ข้อความในส่วนนี้เขียนโดยผู้ใช้ ไม่ใช่ทีม PopNx

เข้าสู่ระบบเพื่อโพสต์

ข้อมูลจาก GitHub

ดาว GitHub
1,826
ผู้ทำ
morganlinton
license
MIT
แก้โค้ดล่าสุด
9 พ.ย. 2569
ไฟล์ SKILL.md ใน repo (นับรวมสำเนาภาษาอื่นและแม่แบบ)
1
topic
agent-skills, claude-code, claude-plugin, claude-skills, clippy, code-review, coding-agent, cursor, rust, style-guide