|
17 | 17 | @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) |
18 | 18 | extension RPCAsyncSequence { |
19 | 19 | /// Returns an ``RPCAsyncSequence`` containing just the given element. |
20 | | - @_spi(Testing) |
21 | | - public static func one(_ element: Element) -> Self { |
| 20 | + @inlinable |
| 21 | + static func one(_ element: Element) -> Self { |
22 | 22 | return Self(wrapping: AsyncSequenceOfOne<Element, Never>(result: .success(element))) |
23 | 23 | } |
24 | 24 |
|
25 | 25 | /// Returns an ``RPCAsyncSequence`` throwing the given error. |
26 | | - @_spi(Testing) |
27 | | - public static func throwing<E: Error>(_ error: E) -> Self { |
| 26 | + @inlinable |
| 27 | + static func throwing<E: Error>(_ error: E) -> Self { |
28 | 28 | return Self(wrapping: AsyncSequenceOfOne<Element, E>(result: .failure(error))) |
29 | 29 | } |
30 | 30 | } |
31 | 31 |
|
32 | 32 | /// An `AsyncSequence` of a single value. |
| 33 | +@usableFromInline |
33 | 34 | @available(macOS 10.15, iOS 13.0, tvOS 13, watchOS 6, *) |
34 | | -private struct AsyncSequenceOfOne<Element: Sendable, Failure: Error>: AsyncSequence { |
35 | | - private let result: Result<Element, Failure> |
| 35 | +struct AsyncSequenceOfOne<Element: Sendable, Failure: Error>: AsyncSequence { |
| 36 | + @usableFromInline |
| 37 | + let result: Result<Element, Failure> |
36 | 38 |
|
| 39 | + @inlinable |
37 | 40 | init(result: Result<Element, Failure>) { |
38 | 41 | self.result = result |
39 | 42 | } |
40 | 43 |
|
| 44 | + @inlinable |
41 | 45 | func makeAsyncIterator() -> AsyncIterator { |
42 | 46 | AsyncIterator(result: self.result) |
43 | 47 | } |
44 | 48 |
|
| 49 | + @usableFromInline |
45 | 50 | struct AsyncIterator: AsyncIteratorProtocol { |
46 | | - private var result: Result<Element, Failure>? |
| 51 | + @usableFromInline |
| 52 | + private(set) var result: Result<Element, Failure>? |
47 | 53 |
|
48 | | - fileprivate init(result: Result<Element, Failure>) { |
| 54 | + @inlinable |
| 55 | + init(result: Result<Element, Failure>) { |
49 | 56 | self.result = result |
50 | 57 | } |
51 | 58 |
|
| 59 | + @inlinable |
52 | 60 | mutating func next() async throws -> Element? { |
53 | 61 | guard let result = self.result else { return nil } |
54 | 62 |
|
|
0 commit comments