Skip to content

Commit 5159a12

Browse files
authored
refactor: mark methods with @discardableResult to silence unused result warnings (#23)
1 parent 47c93d9 commit 5159a12

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Sources/Concurrency/TaskFactory/ITaskFactory.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Foundation
1919
/// - operation: An asynchronous operation to execute within the task. The operation
2020
/// inherits the current actor context and is isolated to that actor.
2121
/// - Returns: A `Task` object that wraps the result or error of the operation.
22+
@discardableResult
2223
func task<Success: Sendable>(
2324
priority: TaskPriority?,
2425
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
@@ -30,6 +31,7 @@ import Foundation
3031
/// - operation: An asynchronous operation to execute within the task. The operation
3132
/// inherits the current actor context and is isolated to that actor.
3233
/// - Returns: A `Task` object that wraps the result of the operation.
34+
@discardableResult
3335
func task<Success: Sendable>(
3436
priority: TaskPriority?,
3537
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
@@ -42,6 +44,7 @@ import Foundation
4244
/// - operation: An asynchronous operation to execute within the task. The operation
4345
/// is isolated and does not inherit the current actor context.
4446
/// - Returns: A `Task` object that wraps the result or error of the operation.
47+
@discardableResult
4548
func detached<Success: Sendable>(
4649
priority: TaskPriority?,
4750
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
@@ -54,6 +57,7 @@ import Foundation
5457
/// - operation: An asynchronous operation to execute within the task. The operation
5558
/// is isolated and does not inherit the current actor context.
5659
/// - Returns: A `Task` object that wraps the result of the operation.
60+
@discardableResult
5761
func detached<Success: Sendable>(
5862
priority: TaskPriority?,
5963
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
@@ -66,6 +70,7 @@ import Foundation
6670
/// that can throw errors.
6771
/// - Parameter operation: An asynchronous operation to execute within the task.
6872
/// - Returns: A `Task` object that wraps the result or error of the operation.
73+
@discardableResult
6974
func task<Success: Sendable>(
7075
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
7176
) -> Task<Success, Error> {
@@ -76,6 +81,7 @@ import Foundation
7681
/// that does not throw errors.
7782
/// - Parameter operation: An asynchronous operation to execute within the task.
7883
/// - Returns: A `Task` object that wraps the result of the operation.
84+
@discardableResult
7985
func task<Success: Sendable>(
8086
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
8187
) -> Task<Success, Never> {
@@ -86,6 +92,7 @@ import Foundation
8692
/// of the current actor context and can throw errors.
8793
/// - Parameter operation: An asynchronous operation to execute within the task.
8894
/// - Returns: A `Task` object that wraps the result or error of the operation.
95+
@discardableResult
8996
func detached<Success: Sendable>(
9097
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
9198
) -> Task<Success, Error> {
@@ -96,6 +103,7 @@ import Foundation
96103
/// of the current actor context and does not throw errors.
97104
/// - Parameter operation: An asynchronous operation to execute within the task.
98105
/// - Returns: A `Task` object that wraps the result of the operation.
106+
@discardableResult
99107
func detached<Success: Sendable>(
100108
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
101109
) -> Task<Success, Never> {

Sources/Concurrency/TaskFactory/TaskFactory.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,31 @@
1111

1212
// MARK: ITaskFactory
1313

14+
@discardableResult
1415
public func task<Success: Sendable>(
1516
priority: TaskPriority?,
1617
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
1718
) -> Task<Success, Error> {
1819
Task(priority: priority, operation: operation)
1920
}
2021

22+
@discardableResult
2123
public func task<Success: Sendable>(
2224
priority: TaskPriority?,
2325
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success
2426
) -> Task<Success, Never> {
2527
Task(priority: priority, operation: operation)
2628
}
2729

30+
@discardableResult
2831
public func detached<Success: Sendable>(
2932
priority: TaskPriority?,
3033
@_inheritActorContext operation: sending @escaping @isolated(any) () async throws -> Success
3134
) -> Task<Success, Error> {
3235
Task.detached(priority: priority, operation: operation)
3336
}
3437

38+
@discardableResult
3539
public func detached<Success: Sendable>(
3640
priority: TaskPriority?,
3741
@_inheritActorContext operation: sending @escaping @isolated(any) () async -> Success

0 commit comments

Comments
 (0)