Skip to content

{flat_,}map_identity: recognize (tuple) struct de- and restructuring #15261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2025

Conversation

ada4a
Copy link
Contributor

@ada4a ada4a commented Jul 12, 2025

Follow-up of #15229, as described in #15229 (comment) -- it turned out to be not that difficult after all!

changelog: [map_identity,flat_map_identity]: also recognize (tuple) struct de- and resctructuring

r? @y21

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 12, 2025
@ada4a ada4a force-pushed the map-identity-struct branch from 156c025 to f73c961 Compare July 13, 2025 14:08
@ada4a ada4a force-pushed the map-identity-struct branch from f73c961 to bdb771e Compare July 29, 2025 20:55
@ada4a
Copy link
Contributor Author

ada4a commented Jul 29, 2025

@y21 friendly ping

Copy link
Member

@y21 y21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you! Sorry for taking a bit longer.
Could you squash the commits?

base check

same fields different struct

reordered fields

different paths to the same struct

same for tuple structs

style: use `zip`-the-function all over the place

makes the code a bit more concise by removing the need for explicit
`.iter()`

style: move precondition checking to the match guard

the match arms above put the "sanity" checks in the guard, and call only
`check_pat` in the body. With this commit, the (tuple) struct cases
follow that convention as well. Well, almost -- I think the ident check
belongs to the second category of checks, so I put it in the body as
well

misc: use `None` in the pattern directly

this'll probably be marginally faster thanks to the equality check being
now structural

move the tests to the right file
@ada4a
Copy link
Contributor Author

ada4a commented Aug 1, 2025

squashed (and rebased)

@ada4a ada4a force-pushed the map-identity-struct branch from bdb771e to eea4d6d Compare August 1, 2025 09:25
@y21 y21 added this pull request to the merge queue Aug 2, 2025
Merged via the queue into rust-lang:master with commit ffcd129 Aug 2, 2025
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 2, 2025
@ada4a ada4a deleted the map-identity-struct branch August 2, 2025 11:53
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.

3 participants