Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Sendables #182

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/Defaults/Defaults+Bridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension Defaults {
}

extension Defaults {
public struct URLBridge: CodableBridge {
public struct URLBridge: CodableBridge, Sendable {
public typealias Value = URL
}
}
Expand Down Expand Up @@ -296,7 +296,7 @@ extension Defaults {
}

extension Defaults {
public struct UUIDBridge: Bridge {
public struct UUIDBridge: Bridge, Sendable {
public typealias Value = UUID
public typealias Serializable = String

Expand Down Expand Up @@ -373,7 +373,7 @@ extension Defaults {

It is unsafe to convert `SwiftUI.Color` to `UIColor` and use `UIColor.bridge` to serialize it, because `UIColor` does not hold a color space, but `Swift.Color` does (which means color space might get lost in the conversion). The bridge will always try to preserve the color space whenever `Color#cgColor` exists. Only when `Color#cgColor` is `nil`, will it use `UIColor.bridge` to do the serialization and deserialization.
*/
public struct ColorBridge: Bridge {
public struct ColorBridge: Bridge, Sendable {
public typealias Value = Color
public typealias Serializable = Any

Expand Down Expand Up @@ -428,7 +428,7 @@ extension Defaults {
}

extension Defaults {
public struct AnyBridge: Defaults.Bridge {
public struct AnyBridge: Defaults.Bridge, Sendable {
public typealias Value = Defaults.AnySerializable
public typealias Serializable = Any

Expand Down
2 changes: 1 addition & 1 deletion Sources/Defaults/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extension Defaults {

- Important: The `UserDefaults` name must be ASCII, not start with `@`, and cannot contain a dot (`.`).
*/
public final class Key<Value: Serializable>: _AnyKey {
public final class Key<Value: Serializable>: _AnyKey, @unchecked Sendable {
/**
It will be executed in these situations:

Expand Down
Loading