From 35943225a081e26b6ef5126312198e884512cbb6 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 18 Nov 2022 10:53:54 +0700 Subject: [PATCH] Remove `DefaultsBaseKey` (#123) --- Sources/Defaults/Defaults.swift | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Sources/Defaults/Defaults.swift b/Sources/Defaults/Defaults.swift index 07cbc31..88c2328 100644 --- a/Sources/Defaults/Defaults.swift +++ b/Sources/Defaults/Defaults.swift @@ -1,22 +1,7 @@ // MIT License © Sindre Sorhus import Foundation -public protocol DefaultsBaseKey { - var name: String { get } - var suite: UserDefaults { get } -} - -extension DefaultsBaseKey { - /** - Reset the item back to its default value. - */ - public func reset() { - suite.removeObject(forKey: name) - } -} - public enum Defaults { - public typealias BaseKey = DefaultsBaseKey public typealias Keys = AnyKey public typealias Serializable = DefaultsSerializable public typealias CollectionSerializable = DefaultsCollectionSerializable @@ -28,7 +13,7 @@ public enum Defaults { typealias CodableBridge = DefaultsCodableBridge // We cannot use `Key` as the container for keys because of "Static stored properties not supported in generic types". - public class AnyKey: BaseKey { + public class AnyKey { public typealias Key = Defaults.Key public let name: String @@ -38,6 +23,13 @@ public enum Defaults { self.name = name self.suite = suite } + + /** + Reset the item back to its default value. + */ + public func reset() { + suite.removeObject(forKey: name) + } } public final class Key: AnyKey {