Skip to content

Commit d0caf39

Browse files
authored
Merge pull request #125 from unsignedapps/keith/cosmetic-fixes
Minor updates to async sequences
2 parents b57afae + 81dcd7b commit d0caf39

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

Sources/Vexil/Observability/Observing.swift

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public typealias FlagChangeStream = AsyncStream<FlagChange>
3333
public struct FilteredFlagChangeStream: AsyncSequence, Sendable {
3434

3535
public typealias Element = FlagChange
36+
public typealias Failure = Never
3637

3738
let sequence: AsyncFilterSequence<FlagChangeStream>
3839

@@ -49,8 +50,25 @@ public struct FilteredFlagChangeStream: AsyncSequence, Sendable {
4950
}
5051
}
5152

52-
public func makeAsyncIterator() -> AsyncFilterSequence<FlagChangeStream>.AsyncIterator {
53-
sequence.makeAsyncIterator()
53+
public struct AsyncIterator: AsyncIteratorProtocol {
54+
var iterator: AsyncFilterSequence<FlagChangeStream>.AsyncIterator
55+
56+
public mutating func next() async -> Element? {
57+
await iterator.next()
58+
}
59+
60+
#if swift(>=6)
61+
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
62+
public mutating func next(
63+
isolation actor: isolated (any Actor)?
64+
) async -> FlagChange? {
65+
await iterator.next(isolation: actor)
66+
}
67+
#endif
68+
}
69+
70+
public func makeAsyncIterator() -> AsyncIterator {
71+
AsyncIterator(iterator: sequence.makeAsyncIterator())
5472
}
5573

5674
}
@@ -62,6 +80,7 @@ public struct FilteredFlagChangeStream: AsyncSequence, Sendable {
6280
public struct EmptyFlagChangeStream: AsyncSequence, Sendable {
6381

6482
public typealias Element = FlagChange
83+
public typealias Failure = Never
6584

6685
public init() {
6786
// Intentionally left blank
@@ -75,10 +94,18 @@ public struct EmptyFlagChangeStream: AsyncSequence, Sendable {
7594

7695
public typealias Element = FlagChange
7796

78-
public func next() async throws -> FlagChange? {
97+
public func next() async -> FlagChange? {
7998
nil
8099
}
81100

101+
#if swift(>=6)
102+
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
103+
public func next(
104+
isolation actor: isolated (any Actor)?
105+
) async -> FlagChange? {
106+
nil
107+
}
108+
#endif
82109
}
83110

84111
}

Sources/Vexil/Value.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public protocol FlagDisplayValue {
6767
///
6868
/// Any custom type you conform to `FlagValue` must be able to be represented using one of these types
6969
///
70-
public enum BoxedFlagValue: Equatable & Sendable {
70+
public enum BoxedFlagValue: Equatable, Sendable {
7171
case array([BoxedFlagValue])
7272
case bool(Bool)
7373
case dictionary([String: BoxedFlagValue])

0 commit comments

Comments
 (0)