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-code

Installs 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

ErrorDon't Just SayAsk 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:

  1. What abstraction is needed?

    • Same behavior, different types → trait
    • Different behavior, same type → enum
    • No abstraction needed → concrete type
  2. When is type known?

    • Compile time → generics (static dispatch)
    • Runtime → trait objects (dynamic dispatch)
  3. 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

Recommended

More Rust
1actionbook avatarm05-type-drivenactionbook/rust-skillsCRITICAL: Use for type-driven design. Triggers: type state, PhantomData, newtype, marker trait, builder pattern, make invalid states unrepresentable, compile-ti3.6Kskills.sh installs
2actionbook avatarm12-lifecycleactionbook/rust-skillsUse when designing resource lifecycles. Keywords: RAII, Drop, resource lifecycle, connection pool, lazy initialization, connection pool design, resource cleanup3.5Kskills.sh installs
3actionbook avatardomain-cliactionbook/rust-skillsUse when building CLI tools. Keywords: CLI, command line, terminal, clap, structopt, argument parsing, subcommand, interactive, TUI, ratatui, crossterm, indicat3.4Kskills.sh installs
4actionbook avatardomain-mlactionbook/rust-skillsUse when building ML/AI apps in Rust. Keywords: machine learning, ML, AI, tensor, model, inference, neural network, deep learning, training, prediction, ndarray3Kskills.sh installs
5actionbook avatarcore-actionbookactionbook/rust-skillsInternal support skill for actionbook MCP selectors used by Rust documentation research workflows. Use only when another rust-skills workflow explicitly request2Kskills.sh installs
6actionbook avatarcore-fix-skill-docsactionbook/rust-skillsInternal maintenance support for checking and fixing generated Rust skill documentation references. Use only when explicitly invoked by /fix-skill-docs.2Kskills.sh installs