Skip to content

Commit

Permalink
Migrate to Swift 6 & add any missing Sendable conformances
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Oct 29, 2024
1 parent 7b7fbf5 commit 20b5165
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version: 6.0
import PackageDescription

let package = Package(
Expand Down
4 changes: 2 additions & 2 deletions Sources/HandySwift/Globals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation
/// - timeInterval: The duration of the delay. E.g., `.seconds(1)` or `.milliseconds(200)`.
/// - qosClass: The global QoS class to be used or `nil` to use the main thread. Defaults to `nil`.
/// - closure: The code to run with a delay.
public func delay(by timeInterval: TimeInterval, qosClass: DispatchQoS.QoSClass? = nil, _ closure: @escaping () -> Void) {
public func delay(by timeInterval: TimeInterval, qosClass: DispatchQoS.QoSClass? = nil, _ closure: @Sendable @escaping () -> Void) {
let dispatchQueue = qosClass != nil ? DispatchQueue.global(qos: qosClass!) : DispatchQueue.main
dispatchQueue.asyncAfter(deadline: DispatchTime.now() + timeInterval, execute: closure)
}
Expand All @@ -19,7 +19,7 @@ public func delay(by timeInterval: TimeInterval, qosClass: DispatchQoS.QoSClass?
/// - closure: The code to run with a delay.
@_disfavoredOverload
@available(iOS 16, macOS 13, tvOS 16, visionOS 1, watchOS 9, *)
public func delay(by duration: Duration, qosClass: DispatchQoS.QoSClass? = nil, _ closure: @escaping () -> Void) {
public func delay(by duration: Duration, qosClass: DispatchQoS.QoSClass? = nil, _ closure: @Sendable @escaping () -> Void) {
let dispatchQueue = qosClass != nil ? DispatchQueue.global(qos: qosClass!) : DispatchQueue.main
dispatchQueue.asyncAfter(deadline: DispatchTime.now() + duration.timeInterval, execute: closure)
}
4 changes: 2 additions & 2 deletions Sources/HandySwift/Types/Debouncer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class Debouncer {
/// }
/// ```
@available(iOS 16, macOS 13, tvOS 16, visionOS 1, watchOS 9, *)
public func delay(for duration: Duration, id: String = "default", operation: @escaping () -> Void) {
public func delay(for duration: Duration, id: String = "default", operation: @Sendable @escaping () -> Void) {
self.cancel(id: id)
self.timerByID[id] = Timer.scheduledTimer(withTimeInterval: duration.timeInterval, repeats: false) { _ in
operation()
Expand All @@ -76,7 +76,7 @@ public final class Debouncer {
/// performOperation()
/// }
/// ```
public func delay(for interval: TimeInterval, id: String = "default", operation: @escaping () -> Void) {
public func delay(for interval: TimeInterval, id: String = "default", operation: @Sendable @escaping () -> Void) {
self.cancel(id: id)
self.timerByID[id] = Timer.scheduledTimer(withTimeInterval: interval, repeats: false) { _ in
operation()
Expand Down
2 changes: 1 addition & 1 deletion Sources/HandySwift/Types/HandyRegex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ extension HandyRegex: Hashable {

extension HandyRegex {
/// `Options` defines alternate behaviours of regular expressions when matching.
public struct Options: OptionSet {
public struct Options: OptionSet, Sendable {
/// Ignores the case of letters when matching.
public static let ignoreCase = Options(rawValue: 1)

Expand Down

0 comments on commit 20b5165

Please sign in to comment.