huiali/rust-skills/rust-lifetime-complex
Claude Code and agent skill by huiali/rust-skills
- community
Checking that the SKILL.md file is still in the repository.
Advanced lifetime expert covering HRTB, GAT, 'static bounds, trait object constraints, type system conflicts, and lifetime elision edge cases.triggers: - lifetime - HRTB - GAT - higher-ranked - 'static - trait object - one type is more general - lifetime conflict--- # Advanced Lifetime and Type System Expert ## Core Question **Why won't this type conversion compile?** The type system's boundaries are often surprising.
Install
npx vskill@latest install huiali/rust-skills/rust-lifetime-complexSKILL.md
Solution Patterns
Pattern 1: HRTB (Higher-Ranked Trait Bounds)
Pattern 2: GAT + Object Safety
Pattern 3: Static Bound Conflicts
Pattern 4: Lifetime Elision Edge Cases
Pattern 5: Async + Lifetime Conflicts
Common Conflict Patterns
| Pattern | Cause | Solution | |
|---|---|---|---|
| HRTB → dyn | Concrete vs universal lifetime | Use generic functions | |
| GAT → dyn | Variable-sized associated types | Layered design with owned DTOs | |
| 'static + borrow | Lifetime contradiction | Return owned data | |
| Async + borrow | Future holds state across await | Clone or drop before await | |
| Closure capture + Send | Lifetime issues | Use 'static or Arc |
When to Give Up Borrowing
Performance vs Maintainability
Rule of Thumb
- API layer: Default to owned data
- Internal impl: Borrow when beneficial
- Performance hotspot: Profile first, then optimize
- High complexity: Fall back to owned
Workflow
Step 1: Diagnose Error
Step 2: Choose Strategy
Step 3: Validate Solution
Debugging Techniques
Minimize
Explicit Lifetimes
Accept Reality
Review Checklist
When dealing with complex lifetimes:
- [ ] HRTB not used with dyn trait objects
- [ ] GAT traits have owned alternative for object safety
- [ ] 'static bounds justified and documented
- [ ] Async functions don't hold borrows across await
- [ ] Lifetime elision not hiding ambiguity
- [ ] Complex lifetimes have explicit annotations
- [ ] Considered owned data alternative
- [ ] Design simplification explored first
Verification Commands
Related Skills
- rust-ownership - Basic lifetime fundamentals
- rust-async - Async lifetime patterns
- rust-type-driven - Type-level design
- rust-trait - Trait object constraints
- rust-performance - When to optimize with borrowing
Localized Reference
- Chinese version: SKILL_ZH.md - 完整中文版本,包含所有内容
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/rust-lifetime-complex/SKILL.md
Popularity
- Repository stars
- 20
- Repository forks
- 4
- 7-day trend score
- 15
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 20 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/huiali/rust-skills/rust-lifetime-complex)