Skip to content

Commit d0426fb

Browse files
committed
Proposal edits, append-in-place additions
1 parent 7c44259 commit d0426fb

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

proposals/nnnn-outputspan.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ extension Array {
5353
}
5454
```
5555

56-
We will also extend `String` and `InlineArray` in a similar manner.
56+
We will also extend `String`, `UnicodeScalarView` and `InlineArray` with similar initializers, and add append-in-place operations where appropriate.
5757

5858
#### `@lifetime` attribute
5959

6060
Some of the API presented here must establish a lifetime relationship between a non-escapable returned value and a callee binding. This relationship will be illustrated using the `@lifetime` attribute recently [pitched][PR-LifetimeAnnotations] and [formalized][Forum-LifetimeAnnotations]. For the purposes of this proposal, the lifetime attribute ties the lifetime of a function's return value to one of its input parameters.
6161

6262
Note: The eventual lifetime annotations proposal may adopt a syntax different than the syntax used here. We expect that the Standard Library will be modified to adopt an updated lifetime dependency syntax as soon as it is finalized.
6363

64-
## Detailed Design
64+
## <a name="design"></a>Detailed Design
6565

6666
#### OutputSpan
6767

@@ -563,18 +563,45 @@ extension Array {
563563
capacity: Int,
564564
initializingWith initializer: (inout OutputSpan<Element>) throws(E) -> Void
565565
) throws(E)
566+
567+
public mutating func append<E: Error>(
568+
addingCapacity: Int,
569+
initializingWith initializer: (inout OutputSpan<Element>) throws(E) -> Void
570+
) throws(E)
566571
}
567572

568573
extension String {
569574
public init<E: Error>(
570-
capacity: Int,
575+
utf8Capacity: Int,
571576
initializingUTF8With initializer: (inout OutputSpan<UTF8.CodeUnit>) throws(E) -> Void
572577
)
573578

574579
public init<E: Error>?(
575-
capacity: Int,
580+
utf8Capacity: Int,
576581
initializingValidUTF8With initializer: (inout OutputSpan<UTF8.CodeUnit>) throws(E) -> Void
577582
) throws(E)
583+
584+
public mutating func append<E: Error>(
585+
addingUTF8Capacity: Int,
586+
initializingUTF8With initializer: (inout OUtputSpan<UTF8.CodeUnit>) throws(E) -> Void
587+
) throws(E)
588+
}
589+
590+
extension UnicodeScalarView {
591+
public init<E: Error>(
592+
utf8Capacity: Int,
593+
initializingUTF8With initializer: (inout OutputSpan<UTF8.CodeUnit>) throws(E) -> Void
594+
)
595+
596+
public init<E: Error>?(
597+
utf8Capacity: Int,
598+
initializingValidUTF8With initializer: (inout OutputSpan<UTF8.CodeUnit>) throws(E) -> Void
599+
) throws(E)
600+
601+
public mutating func append<E: Error>(
602+
addingUTF8Capacity: Int,
603+
initializingUTF8With initializer: (inout OUtputSpan<UTF8.CodeUnit>) throws(E) -> Void
604+
) throws(E)
578605
}
579606

580607
extension InlineArray {

0 commit comments

Comments
 (0)