rust-traits
Installation
SKILL.md
Trait Design and Dispatch
Do not default to dyn Trait. Pick the dispatch mechanism first, then design the trait to fit it.
The Rust default order:
- Closed set → model it as an
enum. - Open set, concrete type known at the call site → use generics /
impl Trait. - True type erasure (plugins, heterogeneous collections) → use
dyn Trait.
This is the same ecosystem guidance as rust-idiomatic Rules 7–8, applied to trait design.
The Central Decision: How to Dispatch
Make the dispatch choice explicitly. Use this decision path: