From ac345ef6133af594c563e303bf1e404f243b1988 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Mon, 22 Aug 2022 15:44:00 -0700 Subject: [PATCH] Settings.swift: ~~consistency~~ --- App/Settings/Settings.swift | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/App/Settings/Settings.swift b/App/Settings/Settings.swift index a4469fb..c0983e8 100644 --- a/App/Settings/Settings.swift +++ b/App/Settings/Settings.swift @@ -43,6 +43,22 @@ extension Dictionary: RawRepresentable where Key == String, Value == String { } } +extension Optional: RawRepresentable where Wrapped == String { + public typealias RawValue = String? + + public init?(rawValue: String?) { + if let rawValue { + self = String(rawValue: rawValue) + } else { + self = .none + } + } + + public var rawValue: String? { + return self + } +} + extension String: RawRepresentable { public typealias RawValue = String @@ -109,20 +125,3 @@ class Settings @SettingProperty(key: "syncServer") public var syncServer: Optional = "https://attractor.severnaya.net" } - -extension Optional: RawRepresentable where Wrapped == String -{ - public init?(rawValue: String?) { - if let rawValue { - self = String(rawValue: rawValue) - } else { - self = .none - } - } - - public var rawValue: String? { - return self - } - - public typealias RawValue = String? -}