rust-collections

Review Rust code for canonical Vec, String, and HashMap usage patterns.

Updated May 26, 2026
One-click install
npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill rust-collections
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-collections
Source: https://github.com/adelabdelgawad/rust-fullstack-agents/tree/main/plugins/rusty/skills/rust-collections
Command: npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill rust-collections

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Vec, String, and HashMap usage in Rust can be error-prone without canonical patterns for safe access, efficient memory usage, and clean APIs.

Core Features & Use Cases

  • Canonical idioms for Vec indexing with get, capacity planning with with_capacity, and iteration by reference.
  • Safe String handling (UTF-8) and HashMap entry API usage to avoid repeated lookups.
  • Real-world scenarios: code reviews and generation tasks across Rust projects to improve safety and readability.

Quick Start

Apply these collection idioms to your codebase to immediately improve safety and readability.

Frequently Asked Questions about rust-collections

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

FAQPage Schema
How do I update a Rust HashMap without doing repeated lookups?

Use the HashMap entry API to update Rust HashMaps without repeated lookups. The entry API provides a canonical pattern for modifying or inserting values in a single pass, eliminating redundant key searches and improving code efficiency.

What is the best way to handle safe indexing for a Vec in Rust?

The best way to handle safe Vec indexing in Rust is using the get method instead of direct indexing. This canonical pattern returns an Option, preventing runtime panics when accessing elements out of bounds.

Why should I avoid taking &Vec or &String as function parameters in Rust?

Avoid taking &Vec or &String as function parameters in Rust because they restrict API flexibility. Using generic slices like &[T] and &str instead is the idiomatic pattern, allowing functions to accept a wider range of types without unnecessary whole-collection cloning.

How do I plan memory capacity for Rust collections like Vec and HashMap?

Plan memory capacity for Rust collections by using the with_capacity constructor before inserting elements. This best practice pre-allocates sufficient memory for Vec and HashMap, preventing frequent reallocations and improving performance during bulk insertions.

When should I use the entry API for Rust HashMap operations?

Use the entry API for Rust HashMap operations when you need to check if a key exists and then insert or update its value conditionally. This canonical pattern ensures clean, efficient updates without performing multiple separate hash lookups.

How do I handle UTF-8 strings safely in Rust?

Handle UTF-8 strings safely in Rust by following canonical String handling patterns. This ensures proper UTF-8 validation and manipulation, preventing invalid byte sequences and avoiding unnecessary whole-collection cloning.