From 4a93312750e80ff41522e78727816a6a803764fc Mon Sep 17 00:00:00 2001 From: ktiays Date: Sun, 7 Apr 2024 01:05:39 +0800 Subject: [PATCH] Update initializer of `Defaults` to use `@autoclosure` --- Sources/CyanUtils/Defaults.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/CyanUtils/Defaults.swift b/Sources/CyanUtils/Defaults.swift index 629fe17..47801a3 100644 --- a/Sources/CyanUtils/Defaults.swift +++ b/Sources/CyanUtils/Defaults.swift @@ -88,13 +88,15 @@ public struct Defaults where T: ConstructibleFromDefaults { } private let `default`: () -> T + @available(*, deprecated, renamed: "init(key:defaultValue:)", message: "Use init(key:defaultValue:) instead") public init(key: String, default: @escaping () -> T) { self.key = key self.default = `default` } - public init(key: String, defaultValue: T) { - self.init(key: key) { defaultValue } + public init(key: String, defaultValue: @autoclosure @escaping () -> T) { + self.key = key + self.default = defaultValue } public var wrappedValue: T {