Repository navigation
refactor: one step per iterator adapter - #504
Merged
Merged
Conversation
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
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four closures passed to
anyormapchained two steps onto the item, so one adapter did both. Each now has one step per adapter, lifting the earlier one into a leadingmaporfilter_map.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 namedshortestrender_tree's length-minus-one moves out of itsmaprather than becoming a secondmap: 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, andself-lintruns 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 allpasses on this branch's tip:cargo fmt -- --check,build,doc,lint,testandself-lint.🤖 Generated with Claude Code
https://claude.ai/code/session_01A65ivJxFWzYSVxtGzcH2PX
Generated by Claude Code