m04-zero-cost

Guide Rust developers in selecting abstractions for generics and trait errors.

1|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/Jylhis/claude-marketplace --skill m04-zero-cost-jylhis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: m04-zero-cost
Source: https://github.com/Jylhis/claude-marketplace/tree/main/plugins/rust-dev/skills/m04-zero-cost
Command: npx skills add https://github.com/Jylhis/claude-marketplace --skill m04-zero-cost-jylhis

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps Rust developers resolve compile‑time errors and design dilemmas around generics, traits, and zero‑cost abstractions, ensuring they choose the right static or dynamic dispatch strategy.

Core Features & Use Cases

  • Error‑Driven Guidance: Maps errors like E0277, E0308, and E0599 to targeted design questions.
  • Decision Framework: Offers clear criteria for when to use generics, impl Trait, or dyn Trait based on compile‑time knowledge and runtime requirements.
  • Reference Tables: Provides quick‑reference charts on dispatch types, code size, and runtime cost.
  • Use Case Example: When a project needs a high‑performance collection of heterogeneous types, the skill advises whether an enum, dyn Trait, or generic solution is appropriate.

Quick Start

Ask the skill to analyze a Rust error like E0277 and receive a recommendation on using a generic or a trait object.

Frequently Asked Questions about m04-zero-cost

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix Rust trait bound errors like E0277 when implementing generics?

To fix Rust E0277 trait bound errors, ensure the required trait is implemented for your type. This skill maps E0277, E0308, and E0599 errors to targeted design questions for selecting correct generic bounds or trait objects.

What is the difference between static dispatch and dynamic dispatch in Rust?

Static dispatch in Rust uses generics for compile-time monomorphization with zero-cost runtime overhead, whereas dynamic dispatch uses trait objects (`dyn Trait`) for runtime flexibility. This skill provides reference tables comparing their code size and runtime cost.

When should I use `impl Trait` versus `dyn Trait` in Rust?

Use `impl Trait` for compile-time static dispatch when the concrete type is known at compile time, and `dyn Trait` for runtime dynamic dispatch with heterogeneous types. This skill offers criteria to decide based on your compile-time knowledge and runtime requirements.

How do I choose between enums and trait objects for heterogeneous collections in Rust?

Choosing between enums and trait objects for Rust collections depends on whether the variants are known at compile time. This skill advises whether an enum, `dyn Trait`, or generic solution is appropriate for achieving high-performance heterogeneous type collections.

Why does my Rust code fail with E0599 when calling a trait method?

Rust error E0599 occurs when a method is not found on a type, often due to missing trait imports or incorrect bounds. This skill analyzes E0599 and other compile-time errors to guide you through resolving trait method visibility and object safety issues.