rust-iterators-closures

Community

Canonical Rust idioms for iterators and closures.

Authoradelabdelgawad
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Canonical reference for iterator and closure idioms in Rust. Detects and fixes: C-style index loops where an iterator adapter fits, unused lazy iterators (map/filter with no terminal), needless intermediate Vec from chained collect+loop, .clone() inside .map() to dodge a borrow, unwrap() inside map/filter instead of collect::<Result<,>>(), oversized move closures capturing large structs by value, and FnOnce/FnMut/Fn bound mismatches (E0525). Covers: iterator laziness, Iterator trait + next, consuming vs non-consuming adapters (map, filter, fold, collect, zip, enumerate), turbofish on collect(), collecting into Result, iter vs iter_mut vs into_iter, Fn/FnMut/FnOnce traits and when each is required, move closures for spawned tasks and 'static bounds, borrow-not-clone discipline, and zero-cost abstraction.

Core Features & Use Cases

  • Replace C-style index loops with iterator adapters
  • Use correct iterator ownership (iter/iter_mut/into_iter) and consuming adapters
  • Detect and avoid common pitfalls (unwrap/expect inside closures, .clone() in map, lazy iterators)

Quick Start

Refactor target loops and closures into idiomatic Rust iterator chains and closures.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: rust-iterators-closures
Download link: https://github.com/adelabdelgawad/rust-fullstack-agents/archive/main.zip#rust-iterators-closures

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 510,000+ vetted skills library on demand.