What problem does it solve?
Rust projects often suffer from tangled module layouts and unclear public APIs, making maintenance and onboarding difficult. This Skill provides patterns for organizing code by domain, using traits to abstract behavior, and employing newtypes to prevent type confusion, enabling safer, more maintainable codebases.
Core Features & Use Cases
- Module Structure: organize code by feature or domain rather than by type, with clearly defined module boundaries.
- Traits for Abstraction: define behavior as traits to enable flexible, testable implementations.
- Builder Pattern: use builders to construct complex configurations in a safe, readable way.
- Newtype Pattern: wrap primitive types to enforce type safety across APIs.
- Function Composition: compose small, reusable functions to build complex logic.
- Extension Traits: add methods to existing types without altering their definitions.
- Guidelines: recommend module visibility rules, trait usage, and minimal public API surfaces.
- Examples: references to typical directory layouts and patterns such as module/mod.rs, cfg attributes, and public exports.
Quick Start
Refactor or scaffold a Rust project to use modular modules, trait abstractions, and newtypes for clean APIs.