Skip to content

Commit 62729fb

Browse files
committed
improve UncheckedCompletion
1 parent 0aab3ce commit 62729fb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Sources/DiffableDataSource.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ struct UncheckedCompletion: @unchecked Sendable {
2222
let block: Block?
2323

2424
init(_ block: Block?) {
25-
self.block = {
26-
dispatchPrecondition(condition: .onQueue(.main))
27-
block?()
25+
if let block {
26+
self.block = {
27+
dispatchPrecondition(condition: .onQueue(.main))
28+
block()
29+
}
30+
} else {
31+
self.block = nil
2832
}
2933
}
3034
}

0 commit comments

Comments
 (0)