Skip to content

Commit cc6682a

Browse files
committed
Remove generalization of the result for Sequence.reduce
1 parent fccc202 commit cc6682a

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

stdlib/public/core/SequenceAlgorithms.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,9 @@ extension Sequence {
663663
///
664664
/// - Complexity: O(*n*), where *n* is the length of the sequence.
665665
@_alwaysEmitIntoClient
666-
public func reduce<Result: ~Copyable, E: Error>(
667-
_ initialResult: consuming Result,
668-
_ nextPartialResult: (borrowing Result, Element) throws(E) -> Result
666+
public func reduce<Result, E: Error>(
667+
_ initialResult: Result,
668+
_ nextPartialResult: (Result, Element) throws(E) -> Result
669669
) throws(E) -> Result {
670670
var accumulator = initialResult
671671
for element in self {
@@ -719,8 +719,8 @@ extension Sequence {
719719
///
720720
/// - Complexity: O(*n*), where *n* is the length of the sequence.
721721
@_alwaysEmitIntoClient
722-
public func reduce<Result: ~Copyable, E: Error>(
723-
into initialResult: consuming Result,
722+
public func reduce<Result, E: Error>(
723+
into initialResult: __owned Result,
724724
_ updateAccumulatingResult: (inout Result, Element) throws(E) -> ()
725725
) throws(E) -> Result {
726726
var accumulator = initialResult

test/api-digester/Outputs/stability-stdlib-source-base.swift.expected

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,11 @@ Func Sequence.forEach(_:) has generic signature change from <Self where Self : S
396396
Func Sequence.forEach(_:) is now without @rethrows
397397

398398
// Adoption of typed throws for Sequence.reduce(_:_:)
399-
Func Sequence.reduce(_:_:) has generic signature change from <Self, Result where Self : Swift.Sequence> to <Self, Result, E where Self : Swift.Sequence, E : Swift.Error, Result : ~Copyable>
400-
Func Sequence.reduce(_:_:) has parameter 0 changing from Default to Owned
399+
Func Sequence.reduce(_:_:) has generic signature change from <Self, Result where Self : Swift.Sequence> to <Self, Result, E where Self : Swift.Sequence, E : Swift.Error>
401400
Func Sequence.reduce(_:_:) is now without @rethrows
402401

403402
// Adoption of typed throws for Sequence.reduce(into:_:)
404-
Func Sequence.reduce(into:_:) has generic signature change from <Self, Result where Self : Swift.Sequence> to <Self, Result, E where Self : Swift.Sequence, E : Swift.Error, Result : ~Copyable>
403+
Func Sequence.reduce(into:_:) has generic signature change from <Self, Result where Self : Swift.Sequence> to <Self, Result, E where Self : Swift.Sequence, E : Swift.Error>
405404
Func Sequence.reduce(into:_:) has parameter 1 type change from (inout Result, Self.Element) throws -> () to (inout Result, Self.Element) throws(E) -> ()
406405
Func Sequence.reduce(into:_:) is now without @rethrows
407406

0 commit comments

Comments
 (0)