Tweaks
This commit is contained in:
parent
8584d1d6ed
commit
0f5a23fcbd
|
@ -33,7 +33,7 @@ extension Defaults {
|
||||||
var value: Any
|
var value: Any
|
||||||
public static let bridge = AnyBridge()
|
public static let bridge = AnyBridge()
|
||||||
|
|
||||||
init<T>(value: T?) {
|
init(value: (some Any)?) {
|
||||||
self.value = value ?? ()
|
self.value = value ?? ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ extension Defaults.Serializable where Self: Codable & RawRepresentable & Default
|
||||||
extension Defaults.Serializable where Self: RawRepresentable {
|
extension Defaults.Serializable where Self: RawRepresentable {
|
||||||
public static var bridge: Defaults.RawRepresentableBridge<Self> { Defaults.RawRepresentableBridge() }
|
public static var bridge: Defaults.RawRepresentableBridge<Self> { Defaults.RawRepresentableBridge() }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Defaults.Serializable where Self: NSSecureCoding & NSObject {
|
extension Defaults.Serializable where Self: NSSecureCoding & NSObject {
|
||||||
public static var bridge: Defaults.NSSecureCodingBridge<Self> { Defaults.NSSecureCodingBridge() }
|
public static var bridge: Defaults.NSSecureCodingBridge<Self> { Defaults.NSSecureCodingBridge() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ extension Defaults {
|
||||||
|
|
||||||
guard
|
guard
|
||||||
selfObject == object as? NSObject,
|
selfObject == object as? NSObject,
|
||||||
let change = change
|
let change
|
||||||
else {
|
else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ extension Defaults {
|
||||||
|
|
||||||
guard
|
guard
|
||||||
object is UserDefaults,
|
object is UserDefaults,
|
||||||
let change = change
|
let change
|
||||||
else {
|
else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ extension Defaults {
|
||||||
@usableFromInline
|
@usableFromInline
|
||||||
internal static func isValidKeyPath(name: String) -> Bool {
|
internal static func isValidKeyPath(name: String) -> Bool {
|
||||||
// The key must be ASCII, not start with @, and cannot contain a dot.
|
// The key must be ASCII, not start with @, and cannot contain a dot.
|
||||||
return !name.starts(with: "@") && name.allSatisfy { $0 != "." && $0.isASCII }
|
!name.starts(with: "@") && name.allSatisfy { $0 != "." && $0.isASCII }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ internal let dynamicSharedObject: UnsafeMutableRawPointer = {
|
||||||
@_transparent
|
@_transparent
|
||||||
@usableFromInline
|
@usableFromInline
|
||||||
internal func runtimeWarn(
|
internal func runtimeWarn(
|
||||||
_ condition: @autoclosure() -> Bool, _ message: @autoclosure () -> String
|
_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String
|
||||||
) {
|
) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#if canImport(OSLog)
|
#if canImport(OSLog)
|
||||||
|
|
|
@ -49,7 +49,7 @@ extension PlainHourMinuteTimeRange: Defaults.Serializable {
|
||||||
typealias Serializable = [PlainHourMinuteTime]
|
typealias Serializable = [PlainHourMinuteTime]
|
||||||
|
|
||||||
func serialize(_ value: Value?) -> Serializable? {
|
func serialize(_ value: Value?) -> Serializable? {
|
||||||
guard let value = value else {
|
guard let value else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ extension CodableEnumForm: Defaults.CodableType {
|
||||||
typealias NativeForm = EnumForm
|
typealias NativeForm = EnumForm
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setCodable<Value: Codable>(forKey keyName: String, data: Value) {
|
private func setCodable(forKey keyName: String, data: some Codable) {
|
||||||
guard
|
guard
|
||||||
let text = try? JSONEncoder().encode(data),
|
let text = try? JSONEncoder().encode(data),
|
||||||
let string = String(data: text, encoding: .utf8)
|
let string = String(data: text, encoding: .utf8)
|
||||||
|
|
Loading…
Reference in New Issue