[Discussion] Add @discardableResult to addTaskUnlessCancelled methods

Good day everyone,

II’d love to hear your thoughts on whether adding @discardableResult to addTaskUnlessCancelled and addImmediateTaskUnlessCancelled is something you’d be interested in. Browsing through code on GitHub reveals that many users of the API are discarding the return value using the _ wildcard pattern. Updating the API to include the @discardableResultattribute would, in my opinion, be a small but welcome ergonomic change. That said, there would be one minor annoyance:

await withTaskGroup { group in // Warning: Result of call to 'withTaskGroup' is unused
  group.addTaskUnlessCancelled { // Updated with '@discardableResult'
    ...
  }
} 

As @discardableResult only suppresses the compiler warning when a function’s return value is unused, the API would still return a Boolean indicating whether the child task was added to the group. As a result, the inferred return type of withTaskGroup would be Bool. However, since this only applies to single-expression uses of withTaskGroup, I don’t consider it a significant enough annoyance to avoid adopting @discardableResult.

Let me know what you think, and have a wonderful day, everyone.