Created
February 10, 2020 15:20
-
-
Save matthewcheok/c8891c5ba5459aa08a62f75955e7f5d6 to your computer and use it in GitHub Desktop.
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
import CasePaths | |
public protocol CaseProviding {} | |
extension CaseProviding { | |
public subscript<Value>(casePath casePath: CasePath<Self, Value>) -> Value? { | |
get { casePath.extract(from: self) } | |
set { | |
guard let value = newValue else { return } | |
self = casePath.embed(value) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment