Skip to content
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

Support matching on partial key paths using is #134

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

lukeredpath
Copy link
Contributor

Updated the signature to be a PartialCaseKeyPath which is all that is required for this function to work.

Makes it possible to write algorithms that operate on a collection of case key paths for a given type, for example:

extension CasePathable {
  func isOneOf<CaseKeyPaths: Sequence>(_ keyPaths: CaseKeyPaths) -> Bool where CaseKeyPaths.Element == PartialCaseKeyPath<Self> {
    keyPaths.contains(where: { self.is($0) })
  }
}

Allow matching against a partial key path.

This makes it easier to write algorithms that operate on a collection of key paths for a type.
@lukeredpath lukeredpath marked this pull request as ready for review December 13, 2023 14:42
Copy link
Member

@mbrandonw mbrandonw left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@stephencelis stephencelis merged commit bba1111 into pointfreeco:main Dec 13, 2023
5 checks passed
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.

None yet

3 participants