Light edit on guides and sequence source docs (rdar://90176127) (#86)

* Light-touch edit on existing guides.

* Light edit on the sequences' source docs.

Co-authored-by: Chris Adamson <cadamson@apple.com>
This commit is contained in:
Chris AdamsonandChris Adamson authored and GitHub committed 2022-03-17 15:14:34 -07:00
1 parent 571bfd1a60
commit 5ac8bb4d07
17 files changed
+95 -78

No files matched your search

@@ -13,10 +13,10 @@
/// of a common architecture for AsyncSequences of UInt8s (i.e. byte streams).
///
/// Bytes are read into an internal buffer of `capacity` bytes via the
/// `readFunction`. Invoking next returns bytes from the internal buffer until it's
/// `readFunction`. Invoking `next()` returns bytes from the internal buffer until it's
/// empty, and then suspends and awaits another invocation of `readFunction` to
/// refill. If `readFunction` returns 0 (indicating nothing was read), next() will
/// return nil from then on. Cancellation is checked before each invocation of
/// refill. If `readFunction` returns 0 (indicating nothing was read), `next()` will
/// return `nil` from then on. Cancellation is checked before each invocation of
/// `readFunction`, which means that many calls to `next()` will not check for
/// cancellation.
///
@@ -56,7 +56,7 @@ public struct AsyncBufferedByteIterator: AsyncIteratorProtocol, Sendable {
buffer = _AsyncBytesBuffer(capacity: capacity, readFunction: readFunction)
}
/// Reads a byte out of the buffer if available. When no bytes are available this will trigger a
/// Reads a byte out of the buffer if available. When no bytes are available, this will trigger
/// the read function to reload the buffer and then return the next byte from that buffer.
@inlinable @inline(__always)
public mutating func next() async throws -> UInt8? {
@@ -18,8 +18,8 @@ extension AsyncSequence {
///
/// - Parameters:
/// - initial: The value to use as the initial value.
/// - transform: A closure that combines the previously reduced result and
/// the next element in the receiving asynchronous sequence.
/// - transform: A closure that combines the previously-reduced result and
/// the next element in the receiving asynchronous sequence, which it returns.
/// - Returns: An asynchronous sequence of the initial value followed by the reduced
/// elements.
@inlinable
@@ -37,8 +37,9 @@ extension AsyncSequence {
///
/// - Parameters:
/// - initial: The value to use as the initial value.
/// - transform: A closure that combines the previously reduced result and
/// the next element in the receiving asynchronous sequence.
/// - transform: A closure that combines the previously-reduced result and
/// the next element in the receiving asynchronous sequence, mutating the
/// previous result instead of returning a value.
/// - Returns: An asynchronous sequence of the initial value followed by the reduced
/// elements.
@inlinable
@@ -13,7 +13,8 @@ extension AsyncSequence {
/// ```
///
/// - Parameter transform: A closure that combines the previously reduced
/// result and the next element in the receiving sequence.
/// result and the next element in the receiving sequence, and returns
/// the result.
/// - Returns: An asynchronous sequence of the reduced elements.
@inlinable
public func reductions(
@@ -10,21 +10,21 @@
//===----------------------------------------------------------------------===//
extension AsyncSequence {
/// Returns an async sequence containing elements of this async sequence with
/// Returns an asynchronous sequence containing elements of this asynchronous sequence with
/// the given separator inserted in between each element.
///
/// Any value of the async sequence's element type can be used as the separator.
/// Any value of the asynchronous sequence's element type can be used as the separator.
///
/// - Parameter separator: Value to insert in between each of this async
/// - Parameter separator: The value to insert in between each of this async
/// sequence’s elements.
/// - Returns: The interspersed async sequence of elements.
/// - Returns: The interspersed asynchronous sequence of elements.
@inlinable
public func interspersed(with separator: Element) -> AsyncInterspersedSequence<Self> {
AsyncInterspersedSequence(self, separator: separator)
}
}
/// An async sequence that presents the elements of a base async sequence of
/// An asynchronous sequence that presents the elements of a base asynchronous sequence of
/// elements with a separator between each of those elements.
public struct AsyncInterspersedSequence<Base: AsyncSequence> {
@usableFromInline
@@ -43,7 +43,7 @@ public struct AsyncInterspersedSequence<Base: AsyncSequence> {
extension AsyncInterspersedSequence: AsyncSequence {
public typealias Element = Base.Element
/// The iterator for an `AsyncInterspersedSequence` async sequence.
/// The iterator for an `AsyncInterspersedSequence` asynchronous sequence.
public struct Iterator: AsyncIteratorProtocol {
@usableFromInline
internal enum State {
@@ -11,7 +11,7 @@
extension Sequence {
/// An asynchronous sequence containing the same elements as this sequence,
/// but on which operations, such as `map` and `filter`, are
/// but on which operations, such as `map` and `filter`, are
/// implemented asynchronously.
@inlinable
public var async: AsyncLazySequence<Self> {
@@ -26,7 +26,7 @@ extension Sequence {
/// asynchronous sequences.
///
/// This functions similarly to `LazySequence` by accessing elemetns sequentially
/// in the iterators next method.
/// in the iterator's `next()` method.
@frozen
public struct AsyncLazySequence<Base: Sequence>: AsyncSequence {
public typealias Element = Base.Element
@@ -11,7 +11,7 @@
extension AsyncSequence {
/// Returns an asynchronous sequence containing the accumulated results of combining the
/// elements of the asynchronous sequence using the given closure.
/// elements of the asynchronous sequence using the given error-throwing closure.
///
/// This can be seen as applying the reduce function to each element and
/// providing the initial value followed by these results as an asynchronous sequence.
@@ -19,7 +19,8 @@ extension AsyncSequence {
/// - Parameters:
/// - initial: The value to use as the initial value.
/// - transform: A closure that combines the previously reduced result and
/// the next element in the receiving asynchronous sequence.
/// the next element in the receiving asynchronous sequence and returns
/// the result. If the closure throws an error, the sequence throws.
/// - Returns: An asynchronous sequence of the initial value followed by the reduced
/// elements.
@inlinable
@@ -30,7 +31,7 @@ extension AsyncSequence {
}
/// Returns an asynchronous sequence containing the accumulated results of combining the
/// elements of the asynchronous sequence using the given closure.
/// elements of the asynchronous sequence using the given error-throwing closure.
///
/// This can be seen as applying the reduce function to each element and
/// providing the initial value followed by these results as an asynchronous sequence.
@@ -38,7 +39,9 @@ extension AsyncSequence {
/// - Parameters:
/// - initial: The value to use as the initial value.
/// - transform: A closure that combines the previously reduced result and
/// the next element in the receiving asynchronous sequence.
/// the next element in the receiving asynchronous sequence, mutating the
/// previous result instead of returning a value. If the closure throws an
/// error, the sequence throws.
/// - Returns: An asynchronous sequence of the initial value followed by the reduced
/// elements.
@inlinable
@@ -47,8 +50,8 @@ extension AsyncSequence {
}
}
/// An asynchronous sequence of applying a transform to the element of an asynchronous sequence and the
/// previously transformed result.
/// An asynchronous sequence of applying an error-throwing transform to the element of
/// an asynchronous sequence and the previously transformed result.
@frozen
public struct AsyncThrowingExclusiveReductionsSequence<Base: AsyncSequence, Element> {
@usableFromInline
@@ -1,6 +1,6 @@
extension AsyncSequence {
/// Returns an asynchronous sequence containing the accumulated results of combining the
/// elements of the asynchronous sequence using the given closure.
/// elements of the asynchronous sequence using the given error-throwing closure.
///
/// This can be seen as applying the reduce function to each element and
/// providing the initial value followed by these results as an asynchronous sequence.
@@ -13,7 +13,8 @@ extension AsyncSequence {
/// ```
///
/// - Parameter transform: A closure that combines the previously reduced
/// result and the next element in the receiving sequence.
/// result and the next element in the receiving sequence. If the closure
/// throws an error, the sequence throws.
/// - Returns: An asynchronous sequence of the reduced elements.
@inlinable
public func reductions(
+2 -1
View File
@@ -44,7 +44,8 @@ extension Dictionary {
/// dictionary.
/// - combine: A closure that is called with the values for any duplicate
/// keys that are encountered. The closure returns the desired value for
/// the final dictionary.
/// the final dictionary, or throws an error if building the dictionary
/// can't proceed.
@inlinable
public init<S: AsyncSequence>(_ keysAndValues: S, uniquingKeysWith combine: (Value, Value) async throws -> Value) async rethrows where S.Element == (Key, Value) {
self.init()
@@ -12,7 +12,7 @@
extension RangeReplaceableCollection {
/// Creates a new instance of a collection containing the elements of an asynchronous sequence.
///
/// - Parameter surce: The asynchronous sequence of elements for the new collection.
/// - Parameter source: The asynchronous sequence of elements for the new collection.
@inlinable
public init<Source: AsyncSequence>(_ source: Source) async rethrows where Source.Element == Element {
self.init()