Skip to content

Commit

Permalink
Added a convenience is function for optional CasePathable values (#204
Browse files Browse the repository at this point in the history
)

* Added a convenience `is` function for optional CasePathable values

* Added some docs

* Update Sources/CasePaths/Optional+CasePathable.swift

---------

Co-authored-by: Stephen Celis <[email protected]>
  • Loading branch information
HarshilShah and stephencelis authored Oct 10, 2024
1 parent c805972 commit ed5dd9a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/CasePaths/Optional+CasePathable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ extension Optional.AllCasePaths: Sequence {
[\.none, \.some].makeIterator()
}
}

extension Optional where Wrapped: CasePathable {
@_disfavoredOverload
@_documentation(visibility:internal)
public func `is`(_ keyPath: PartialCaseKeyPath<Wrapped>) -> Bool {
self?[case: keyPath] != nil
}
}

0 comments on commit ed5dd9a

Please sign in to comment.