Add Interspersed proposal (#259)

* Clean up old evolution proposals

# Motivation

Our old proposals had a couple of stale links and were not all aligned. This cleans them up.

* Add Interspersed proposal

# Motivation
Add a new evolution proposal for the interspersed algorithm.
This commit is contained in:
Franz Busch authored and GitHub committed 2023-05-10 15:18:41 +01:00
1 parent 0c00af2372
commit b3394663fd
3 files changed
+176 -20

No files matched your search

@@ -10,10 +10,21 @@
//===----------------------------------------------------------------------===//
extension AsyncSequence {
/// Returns an asynchronous sequence containing elements of this asynchronous sequence with
/// the given separator inserted in between each element.
/// Returns a new asynchronous sequence containing the elements of this asynchronous sequence, inserting
/// the given separator between each element.
///
/// Any value of the asynchronous sequence's element type can be used as the separator.
/// Any value of this asynchronous sequence's element type can be used as the separator.
///
/// The following example shows how an async sequences of `String`s can be interspersed using `-` as the separator:
///
/// ```
/// let input = ["A", "B", "C"].async
/// let interspersed = input.interspersed(with: "-")
/// for await element in interspersed {
/// print(element)
/// }
/// // Prints "A" "-" "B" "-" "C"
/// ```
///
/// - Parameter separator: The value to insert in between each of this async
/// sequence’s elements.
@@ -95,8 +106,11 @@ extension AsyncInterspersedSequence: AsyncSequence {
@inlinable
public func makeAsyncIterator() -> AsyncInterspersedSequence<Base>.Iterator {
Iterator(base.makeAsyncIterator(), separator: separator)
Iterator(base.makeAsyncIterator(), separator: separator)
}
}
extension AsyncInterspersedSequence: Sendable where Base: Sendable, Base.Element: Sendable { }
@available(*, unavailable)
extension AsyncInterspersedSequence.Iterator: Sendable {}