rust-syntax-gats

Installation
SKILL.md

rust-syntax-gats

The mechanics of Generic Associated Types (GATs): how to declare an associated type that takes its own lifetime or type parameters, why the compiler frequently demands where Self: 'a bounds on lifetime GATs, why a trait that uses GATs ceases to be dyn-compatible, and the canonical patterns (lending iterator, callback registry, pointer family) that finally became expressible after the 1.65 stabilization.

Cross-references: [[rust-syntax-traits]] (regular associated types and trait mechanics) [[rust-syntax-generics]] (type and lifetime parameters) [[rust-syntax-lifetimes]] (how 'a flows through signatures) [[rust-syntax-trait-objects]] (a trait with GATs is NOT dyn-compatible).


When to use this skill

  • User writes type Item<'a> or type Output<T> inside a trait
  • User wants to write a next() whose returned value borrows from &mut self (lending iterator)
  • User asks how to express "the associated type depends on a lifetime / type parameter that varies per call"
  • User imports frunk, fp-rust, or another higher-kinded-type emulation crate to work around a missing GAT
  • User hits the trait ... is not dyn compatible after adding type X<'a> and asks why
  • User hits the parameter type Self may not live long enough on a GAT impl and needs the fix
  • User confuses GAT bounds (Self::Item<'a>: Bound) with regular associated-type bounds (Self::Item: Bound)

For regular (non-generic) associated types see [[rust-syntax-traits]]. For dyn Trait consequences see [[rust-syntax-trait-objects]].

Installs
2
GitHub Stars
1
First Seen
May 24, 2026