# Simplify Rust If-Let Control Flow

Nested pattern matching can hide the main decision path in Rust code. This skill helps Claude, Codex, and Claude Code suggest let chains for clearer Rust 2024 control flow.

## Install

```bash
npx skillstore add emillindfors/let-chains-advisor
```

## Metadata

- Status: approved
- Slug: emillindfors-let-chains-advisor
- Version: 1.0.0
- Author version: 1.0.0
- Skillstore revision: r1
- Version status: valid
- Tree hash: c18711efc8a682e3fdccb47d3f8e5f607913d1738379ccbd7b14baaccd31a580
- Author: EmilLindfors
- GitHub username: EmilLindfors
- License: MIT
- Repository: https://github.com/EmilLindfors/claude-marketplace/tree/main/plugins/rust-modern-patterns/skills/let-chains-advisor
- Ref: a06681402992ceae98ba04d54cfd4ab004862696
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands
- Quality score: 81
- Quality tier: silver
- Public page: https://skillstore.pages.dev/skills/emillindfors-let-chains-advisor
- Manifest: https://skillstore.pages.dev/api/skills/emillindfors-let-chains-advisor/manifest

## Capabilities

- Detects deeply nested if-let expressions with three or more levels.
- Suggests Rust 2024 let chain refactors for Option and Result handling.
- Combines pattern matches with boolean guard conditions when appropriate.
- Checks that the project targets Rust 1.88 or newer and edition 2024.
- Provides before-and-after guidance for cleaner control flow.

## Use Cases

- Refactor Nested Option Handling: Replace multiple nested Option checks with a shorter let chain while keeping fallback behavior clear.
- Review Pattern Matching Readability: Identify control flow that is hard to scan and suggest modern Rust syntax where it fits.
- Modernize Rust 2024 Code: Apply let chains to eligible code during an edition upgrade or cleanup pass.

## Prompt Templates

### Find Basic Let Chain Opportunities

```
Review this Rust function for nested if-let expressions. Suggest a let chain only if it improves readability and the code targets Rust 2024.
```

### Refactor Option and Result Flow

```
Scan this Rust module for nested Option or Result checks. Recommend let chain refactors and explain any cases that should stay unchanged.
```

### Evaluate Guards and Pattern Matches

```
Analyze these nested pattern matches and boolean guards. Propose Rust 2024 let chains where ordering, readability, and behavior remain clear.
```

### Prepare an Edition Upgrade Review

```
Review this Rust 2021 code for Rust 2024 let chain opportunities. Note version requirements, semantic risks, and tests that should verify the refactor.
```

## Limitations

- Requires Rust 1.88 or newer with edition 2024 for let chains.
- Does not execute cargo, rustc, tests, or formatters by itself.
- Cannot prove semantic equivalence without project-specific review.
- May need adjustment when borrowing or ownership rules affect the refactor.

## Best Practices

- Confirm the Rust version and edition before applying let chains.
- Keep let chains short enough that the success path remains easy to read.
- Review ownership and borrowing changes after each refactor.

## Anti Patterns

- Do not replace simple two-level checks when nesting is already clear.
- Do not use let chains if they hide important error handling behavior.
- Do not refactor without tests for branches that return early or fall through.

## Security Audit

- Audited at: 2026-07-06T14:58:56.487\+00:00
- Summary: All static findings are false positives caused by Markdown code fences around Rust and TOML examples in SKILL.md. No evidence found of external command execution, prompt injection, data exfiltration, network access, or unsafe tool permissions.

## Stats

- Views: 131
- Downloads: 11
- Favorites: 0
- Popularity score: 0
