From 9dcd0b8f429ff37b6eaebf8247ca621f00ea3fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 24 Jan 2020 07:45:20 +0100 Subject: [PATCH] Fix KeyPathRefining for compiler(<5.1) --- GRDB/Utils/KeyPathRefining.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/GRDB/Utils/KeyPathRefining.swift b/GRDB/Utils/KeyPathRefining.swift index beda0ab41..36639f80a 100644 --- a/GRDB/Utils/KeyPathRefining.swift +++ b/GRDB/Utils/KeyPathRefining.swift @@ -20,6 +20,15 @@ extension KeyPathRefining { return result } + #if compiler(<5.1) + @inlinable + func with(_ keyPath: WritableKeyPath, _ value: T) -> Self { + var result = self + result[keyPath: keyPath] = value + return result + } + #endif + @inlinable func map(_ keyPath: WritableKeyPath, _ transform: (T) throws -> T) rethrows -> Self { var result = self