Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 17, 2023
1 parent 8584d1d commit 0f5a23f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Sources/Defaults/Defaults+AnySerializable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension Defaults {
var value: Any
public static let bridge = AnyBridge()

init<T>(value: T?) {
init(value: (some Any)?) {
self.value = value ?? ()
}

Expand Down
1 change: 1 addition & 0 deletions Sources/Defaults/Defaults+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ extension Defaults.Serializable where Self: Codable & RawRepresentable & Default
extension Defaults.Serializable where Self: RawRepresentable {
public static var bridge: Defaults.RawRepresentableBridge<Self> { Defaults.RawRepresentableBridge() }
}

extension Defaults.Serializable where Self: NSSecureCoding & NSObject {
public static var bridge: Defaults.NSSecureCodingBridge<Self> { Defaults.NSSecureCodingBridge() }
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Defaults/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ extension Defaults {

/**
Create a key with a dynamic default value.
This can be useful in cases where you cannot define a static default value as it may change during the lifetime of the app.
```swift
Expand Down
4 changes: 2 additions & 2 deletions Sources/Defaults/Observation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ extension Defaults {

guard
selfObject == object as? NSObject,
let change = change
let change
else {
return
}
Expand Down Expand Up @@ -265,7 +265,7 @@ extension Defaults {

guard
object is UserDefaults,
let change = change
let change
else {
return
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Defaults/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ extension Defaults {
@usableFromInline
internal static func isValidKeyPath(name: String) -> Bool {
// 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 }
}
}

Expand Down Expand Up @@ -259,7 +259,7 @@ internal let dynamicSharedObject: UnsafeMutableRawPointer = {
@_transparent
@usableFromInline
internal func runtimeWarn(
_ condition: @autoclosure() -> Bool, _ message: @autoclosure () -> String
_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String
) {
#if DEBUG
#if canImport(OSLog)
Expand Down
2 changes: 1 addition & 1 deletion Tests/DefaultsTests/DefaultsCustomBridgeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension PlainHourMinuteTimeRange: Defaults.Serializable {
typealias Serializable = [PlainHourMinuteTime]

func serialize(_ value: Value?) -> Serializable? {
guard let value = value else {
guard let value else {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/DefaultsTests/DefaultsMigrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ extension CodableEnumForm: Defaults.CodableType {
typealias NativeForm = EnumForm
}

private func setCodable<Value: Codable>(forKey keyName: String, data: Value) {
private func setCodable(forKey keyName: String, data: some Codable) {
guard
let text = try? JSONEncoder().encode(data),
let string = String(data: text, encoding: .utf8)
Expand Down

0 comments on commit 0f5a23f

Please sign in to comment.