
M04 Zero Cost
Before you slap another trait bound on that generic function, this prompts you to ask whether you actually need the abstraction. It maps common type errors like E0277 and E0308 to design questions: is this really compile time polymorphism, or should it be an enum, or just a concrete type? The quick reference tables are genuinely useful, showing you when static dispatch bloats your binary versus when dynamic dispatch costs you a vtable lookup. The trace up/down sections connect abstraction choices to other skills in the marketplace, which matters when your "simple" generic suddenly needs Send bounds or domain redesign. Honest take: most Rust codebases over-abstract early, and this at least makes you pause first.
- skills.sh installs
- 3.6K
- GitHub stars
- 1.6K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add actionbook/rust-skills --skill m04-zero-cost --agent claude-codeInstalls into .claude/skills of the current project.
Files
Zero-Cost Abstraction
Layer 1: Language Mechanics
Core Question
Do we need compile-time or runtime polymorphism?
Before choosing between generics and trait objects:
- Is the type known at compile time?
- Is a heterogeneous collection needed?
- What's the performance priority?
Error → Design Question
| Error | Don't Just Say | Ask Instead |
|---|---|---|
| E0277 | "Add trait bound" | Is this abstraction at the right level? |
| E0308 | "Fix the type" | Should types be unified or distinct? |
| E0599 | "Import the trait" | Is the trait the right abstraction? |
| E0038 | "Make object-safe" | Do we really need dynamic dispatch? |
Thinking Prompt
Before adding trait bounds:
-
What abstraction is needed?
- Same behavior, different types → trait
- Different behavior, same type → enum
- No abstraction needed → concrete type
-
When is type known?
- Compile time → generics (static dispatch)
- Runtime → trait objects (dynamic dispatch)
-
What's the trade-off priority?
- Performance → generics
- Compile time → trait objects
- Flexibility → depends
Trace Up ↑
Sponsors
Details
- Repository
- github.com/actionbook/rust-skills
- Category
- Rust
- First seen
- May 16, 2026
More from actionbook/rust-skills
All 38- M05 Type Driven3.6K
- M02 Resource3.6K
- M03 Mutability3.6K
- Rust Refactor Helper3.6K
- M12 Lifecycle3.5K
- M09 Domain3.5K
- M14 Mental Model3.5K
- M11 Ecosystem3.5K
- M13 Domain Error3.5K
- Unsafe Checker3.5K
- Rust Code Navigator3.4K
- Rust Trait Explorer3.4K
- Rust Call Graph3.4K
- Rust Symbol Analyzer3.4K
- Domain Web3.4K
- Domain Cli3.4K
- Rust Learner3.3K
- Rust Skill Creator3.3K
- Rust Deps Visualizer3.2K
- Meta Cognition Parallel3.2K
- Rust Daily3.2K
- Domain Embedded3.1K
- Domain Cloud Native3K
- Domain Fintech3K