Skip to content

refactor: one step per iterator adapter - #504

Merged
KSXGitHub merged 1 commit into
masterfrom
claude/one-step-per-adapter
Oct 3, 2026
Merged

KSXGitHub merged 1 commit into
masterfrom
claude/one-step-per-adapter

Conversation

@KSXGitHub

Copy link
Copy Markdown
Owner

Four closures passed to any or map chained two steps onto the item, so one adapter did both. Each now has one step per adapter, lifting the earlier one into a leading map or filter_map.

file before after
src/rules/bare_issue_reference.rs .any(|line| line.trim_start().starts_with(&label)) .map(str::trim_start).any(|line| line.starts_with(&label))
src/rules/core_instead_of_std/config.rs .any(|segment| segment.trim().is_empty()) .map(|segment| segment.trim()).any(str::is_empty)
src/rules/folded_command_setter/setter.rs .any(|argument| argument.as_type().is_some_and(|ty| ty.has_param())) .filter_map(|argument| argument.as_type()).any(|ty| ty.has_param())
src/rules/named_prelude_imports/statement.rs .map(|segments| segments.len().saturating_sub(1)) .map(Vec::len), then the subtraction on a named shortest

render_tree's length-minus-one moves out of its map rather than becoming a second map: the shortest path is a value worth a name, and the comment about keeping the last segment now sits on the line it explains.

Why

perfectionist::splittable_adapter_closure, which KSXGitHub/perfectionist#503 adds, flags this shape, and self-lint runs the catalogue's rules over the crate's own source under -D warnings. These four are the findings; the refactor stands on its own, so it lands separately from the rule.

Verification

PERFECTIONIST_CARGO_LOCKED=true just all passes on this branch's tip: cargo fmt -- --check, build, doc, lint, test and self-lint.

🤖 Generated with Claude Code

https://claude.ai/code/session_01A65ivJxFWzYSVxtGzcH2PX


Generated by Claude Code

Four closures passed to `any` or `map` chained two steps onto the
item, so one adapter did both. Each now has one step per adapter,
lifting the earlier one into a leading `map` or `filter_map`.

`render_tree`'s length-minus-one also moves out of its `map`: the
shortest path is a value worth a name, and the comment about keeping
the last segment now sits on the line it explains.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A65ivJxFWzYSVxtGzcH2PX
@KSXGitHub
KSXGitHub marked this pull request as ready for review October 3, 2026 13:53
@KSXGitHub
KSXGitHub merged commit 169115f into master Oct 3, 2026
6 checks passed
@KSXGitHub
KSXGitHub deleted the claude/one-step-per-adapter branch October 3, 2026 14:15

This branch was successfully deployed

1 active deployment
cloudflare-preview — 7c5deb04 Deployed Oct 3, 2026 by KSXGitHub via Build and deploy preview #1546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants