Skip to content

Commit fa69ab7

Browse files
committed
[SE-0437] Amend with small corrections
- Fix accidental omission of `UnboundedRange`-taking overloads of `extracting`. - Reflect SE-0427’s outcome and add explicit `where Foo: Copyable` clauses for conditional conformances to Copyable. - Fix typo where `Result` forgot to declare itself `~Copyable` - Fix typo where an `withExtendedLifetime(_:_:)` overload was shown with a signature requiring copyable Ts.
1 parent cd8dacd commit fa69ab7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

proposals/0437-noncopyable-stdlib-primitives.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ enum Optional<Wrapped: ~Copyable>: ~Copyable {
141141
case some(Wrapped)
142142
}
143143

144-
extension Optional: Copyable /* where Wrapped: Copyable */ {}
144+
extension Optional: Copyable where Wrapped: Copyable {}
145145
```
146146

147147
This is no small matter -- every existing use of `Optional` implicitly assumes its copyability, including all its protocol conformances. We need to lift this assumption without breaking source- and (on some platforms) binary compatibility with existing code that relies on it.
@@ -596,12 +596,12 @@ The standard `Result` type similarly needs to be generalized to allow noncopyabl
596596

597597
```swift
598598
@frozen
599-
enum Result<Success: ~Copyable, Failure: Error> {
599+
enum Result<Success: ~Copyable, Failure: Error>: ~Copyable {
600600
case success(Success)
601601
case failure(Failure)
602602
}
603603

604-
extension Result: Copyable /* where Success: Copyable */ {}
604+
extension Result: Copyable where Success: Copyable {}
605605
extension Result: Sendable where Success: Sendable & ~Copyable {}
606606
```
607607

@@ -992,11 +992,13 @@ We therefore propose to add the following new member methods for extracting a st
992992
extension UnsafeBufferPointer where Element: ~Copyable {
993993
func extracting(_ bounds: Range<Int>) -> Self
994994
func extracting(_ bounds: some RangeExpression<Int>) -> Self
995+
func extracting(_ bounds: UnboundedRange) -> Self
995996
}
996997

997998
extension UnsafeMutableBufferPointer where Element: ~Copyable {
998999
func extracting(_ bounds: Range<Int>) -> Self
9991000
func extracting(_ bounds: some RangeExpression<Int>) -> Self
1001+
func extracting(_ bounds: UnboundedRange) -> Self
10001002
}
10011003
```
10021004

@@ -1179,7 +1181,7 @@ func withExtendedLifetime<T: ~Copyable, E: Error, Result: ~Copyable>(
11791181
There exists a second variant of `withExtendedLifetime` whose function argument is passed the entity whose lifetime is being extended. This variant is less frequently used, but it still makes sense to generalize this to pass a borrowed instance:
11801182

11811183
```swift
1182-
func withExtendedLifetime<T, E: Error, Result: ~Copyable>(
1184+
func withExtendedLifetime<T: ~Copyable, E: Error, Result: ~Copyable>(
11831185
_ x: borrowing T,
11841186
_ body: (borrowing T) throws(E) -> Result
11851187
) throws(E) -> Result

0 commit comments

Comments
 (0)