Skip to content

Allow run body closures to return noncopyable values#305

Merged
iCharlesHu merged 1 commit into
swiftlang:mainfrom
iCharlesHu:charles/non-copyable-result
Jun 9, 2026
Merged

Allow run body closures to return noncopyable values#305
iCharlesHu merged 1 commit into
swiftlang:mainfrom
iCharlesHu:charles/non-copyable-result

Conversation

@iCharlesHu

Copy link
Copy Markdown
Contributor

The value a run() body closure returns may now be ~Copyable, so a closure can hand back a move-only resource. ExecutionResult and the internal ExecutionOutcome are now conditionally Copyable/Sendable: copyable exactly when the closure result is, so existing Copyable usages are unaffected

Add ExecutionResult.takeClosureResult() as a consuming accessor when closure result is ~Copyable to allow closure result to be moved out

Rename closureOutput to closureResult to match the ClosureResult generic parameter and the doc comment

The value a run() body closure returns may now be ~Copyable, so a closure can hand back a move-only resource. ExecutionResult and the internal ExecutionOutcome are now conditionally Copyable/Sendable: copyable exactly when the closure result is, so existing Copyable usages are unaffected

Add ExecutionResult.takeClosureResult() as a consuming accessor when closure result is ~Copyable to allow closure result to be moved out

Rename closureOutput to closureResult to match the ClosureResult generic parameter and the doc comment
@iCharlesHu iCharlesHu force-pushed the charles/non-copyable-result branch from 1172373 to aae73aa Compare June 9, 2026 16:11
@iCharlesHu iCharlesHu merged commit 6e623d3 into swiftlang:main Jun 9, 2026
91 of 92 checks passed
@iCharlesHu iCharlesHu deleted the charles/non-copyable-result branch June 9, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants