Skip to content

Commit

Permalink
Add Swift 6.0 iterator method
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Oct 1, 2024
1 parent fba0143 commit c0d9233
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/Inotify/Inotifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ public final actor Inotifier {
@frozen
public struct PathEvents: AsyncSequence, Sendable {
public typealias Element = AsyncIterator.Element
public typealias Failure = AsyncIterator.Failure

@frozen
public struct AsyncIterator: AsyncIteratorProtocol {
public typealias Element = InotifyEvent
public typealias Failure = Never

@usableFromInline
var underlyingIterator: AsyncStream<Element>.AsyncIterator
Expand All @@ -37,6 +39,13 @@ public final actor Inotifier {
public mutating func next() async -> Element? {
await underlyingIterator.next()
}

#if swift(>=6.0)
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
public mutating func next(isolation actor: isolated (any Actor)?) async throws(Failure) -> InotifyEvent? {
await underlyingIterator.next(isolation: actor)
}
#endif
}

@usableFromInline
Expand Down

0 comments on commit c0d9233

Please sign in to comment.