rust-coding-style

Enforce PepperDB Rust coding style with iterator chains and field macros.

Updated Sep 4, 2023
One-click install
npx skills add https://github.com/qsliu2017/PepperDB --skill rust-coding-style-qsliu2017
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-coding-style
Source: https://github.com/qsliu2017/PepperDB/tree/main/.claude/skills/rust-coding-style
Command: npx skills add https://github.com/qsliu2017/PepperDB --skill rust-coding-style-qsliu2017

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill ensures consistent and idiomatic Rust code within the PepperDB project, improving maintainability and reducing cognitive load for developers.

Core Features & Use Cases

  • Code Organization: Guides developers on merging helper functions into their owning structs and using private methods.
  • Idiomatic Iterators: Promotes the use of iterator chains (.fold(), .map(), etc.) over mutable accumulators for cleaner, more functional code.
  • Macro Usage: Advocates for page_field! and tuple_field! macros for defining fixed-offset struct fields, ensuring a single source of truth for field definitions.
  • Use Case: When writing a new function or refactoring existing code, consult this Skill to ensure it adheres to PepperDB's Rust coding conventions.

Quick Start

Use the rust-coding-style skill to refactor the provided Rust code snippet to use iterator chains instead of mutable accumulators.

Frequently Asked Questions about rust-coding-style

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

FAQPage Schema
How do I enforce idiomatic Rust coding standards for a database project?

To enforce idiomatic Rust coding standards for a database project, apply specific rules for code organization, prefer iterator chains over mutable accumulators, and use designated macros for struct field definitions to ensure consistency.

What is the best way to refactor Rust code to use iterator chains?

The best way to refactor Rust code to use iterator chains is to replace mutable accumulators with functional iterator methods like .fold() and .map(), creating cleaner and more maintainable code.

How do I organize helper functions in idiomatic Rust code?

To organize helper functions in idiomatic Rust code, merge them directly into their owning structs and convert them into private methods, reducing scattered standalone functions and improving structural encapsulation.

When should I use macros for struct field definitions in Rust?

You should use macros for struct field definitions in Rust when working with fixed-offset fields, utilizing specific macros like page_field! and tuple_field! to maintain a single source of truth for field layouts.

Does this Rust refactoring guidance apply to general Rust development or a specific repository?

This Rust refactoring guidance applies specifically to the PepperDB project repository, enforcing strict coding conventions for all Rust code development and refactoring tasks within that particular codebase.

Why should I prefer iterator chains over mutable accumulators in Rust?

You should prefer iterator chains over mutable accumulators in Rust because functional patterns like .map() and .fold() reduce cognitive load, yield cleaner code, and improve overall project maintainability.