Fix KeyPathRefining for compiler(<5.1)

This commit is contained in:
Gwendal Roué committed 2020-01-24 07:45:20 +01:00
1 parent 349e34b1c1
commit 9dcd0b8f42
1 file changed
+9
+9
View File
@@ -20,6 +20,15 @@ extension KeyPathRefining {
return result
}
#if compiler(<5.1)
@inlinable
func with<T>(_ keyPath: WritableKeyPath<Self, T?>, _ value: T) -> Self {
var result = self
result[keyPath: keyPath] = value
return result
}
#endif
@inlinable
func map<T>(_ keyPath: WritableKeyPath<Self, T>, _ transform: (T) throws -> T) rethrows -> Self {
var result = self