rust-syntax-traits

Installation
SKILL.md

rust-syntax-traits

The mechanics of trait declaration and implementation in Rust: how to define a trait, how default methods work, how supertraits compose, how the orphan rule and coherence constrain impl Trait for Type, how to seal a trait against external implementors, and which built-in marker traits (Send, Sync, Sized, Copy, Unpin) have special compiler treatment.

Cross-references: [[rust-syntax-generics]] (trait bounds on type parameters) [[rust-syntax-trait-objects]] (dyn Trait and dyn-compatibility) [[rust-syntax-gats]] (associated types with generics) [[rust-errors-trait-bounds]] (E-codes for unsatisfied bounds) [[rust-core-memory-model]] (Send / Sync auto-trait rules)


When to use this skill

  • User writes trait Foo { ... } or impl Trait for Type { ... } and needs the rules
  • User hits an orphan-rule error (E0117) or coherence error (E0119) and asks how to fix it
  • User needs to add a method to a trait without breaking downstream implementors
  • User asks about Send / Sync / Sized / Copy / Unpin and how to opt in or out
  • User wants to write an extensible-looking trait that only the defining crate may implement (sealed trait)
  • User confuses inherent methods (impl Foo) with trait methods (impl Trait for Foo)
  • User asks about #[derive(...)] and which derives are available in std

For dyn Trait and object safety see [[rust-syntax-trait-objects]]. For generic-parameter trait bounds (fn foo<T: Trait>()) see [[rust-syntax-generics]].

Installs
2
GitHub Stars
1
First Seen
May 24, 2026