Skip to content

Commit 5e2c815

Browse files
Mark reversed as consuming (#19617)
1 parent d401f96 commit 5e2c815

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

stdlib/public/core/Reverse.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ extension ReversedCollection {
257257
/// - Complexity: O(1)
258258
@inlinable
259259
@available(swift, introduced: 4.2)
260-
public func reversed() -> Base {
260+
public __consuming func reversed() -> Base {
261261
return _base
262262
}
263263
}
@@ -289,7 +289,7 @@ extension BidirectionalCollection {
289289
///
290290
/// - Complexity: O(1)
291291
@inlinable
292-
public func reversed() -> ReversedCollection<Self> {
292+
public __consuming func reversed() -> ReversedCollection<Self> {
293293
return ReversedCollection(_base: self)
294294
}
295295
}
@@ -303,7 +303,7 @@ extension LazyCollectionProtocol
303303
///
304304
/// - Complexity: O(1)
305305
@inlinable
306-
public func reversed() -> LazyCollection<ReversedCollection<Elements>> {
306+
public __consuming func reversed() -> LazyCollection<ReversedCollection<Elements>> {
307307
return ReversedCollection(_base: elements).lazy
308308
}
309309
}

stdlib/public/core/SequenceAlgorithms.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ extension Sequence {
750750
///
751751
/// - Complexity: O(*n*), where *n* is the length of the sequence.
752752
@inlinable
753-
public func reversed() -> [Element] {
753+
public __consuming func reversed() -> [Element] {
754754
// FIXME(performance): optimize to 1 pass? But Array(self) can be
755755
// optimized to a memcpy() sometimes. Those cases are usually collections,
756756
// though.

0 commit comments

Comments
 (0)