Skip to content

Move platform requirements to availability annotations #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import PackageDescription

let package = Package(
name: "swift-async-algorithms",
platforms: [
.macOS("10.15"),
.iOS("13.0"),
.tvOS("13.0"),
.watchOS("6.0"),
],
products: [
.library(name: "AsyncAlgorithms", targets: ["AsyncAlgorithms"])
],
Expand Down
6 changes: 0 additions & 6 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import PackageDescription

let package = Package(
name: "swift-async-algorithms",
platforms: [
.macOS("10.15"),
.iOS("13.0"),
.tvOS("13.0"),
.watchOS("6.0"),
],
products: [
.library(name: "AsyncAlgorithms", targets: ["AsyncAlgorithms"]),
.library(name: "AsyncSequenceValidation", targets: ["AsyncSequenceValidation"]),
Expand Down
3 changes: 3 additions & 0 deletions Sources/AsyncAlgorithms/AsyncAdjacentPairsSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence {
/// An `AsyncSequence` that iterates over the adjacent pairs of the original
/// original `AsyncSequence`.
Expand All @@ -35,6 +36,7 @@ extension AsyncSequence {
/// An `AsyncSequence` that iterates over the adjacent pairs of the original
/// `AsyncSequence`.
@frozen
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncAdjacentPairsSequence<Base: AsyncSequence>: AsyncSequence {
public typealias Element = (Base.Element, Base.Element)

Expand Down Expand Up @@ -83,6 +85,7 @@ public struct AsyncAdjacentPairsSequence<Base: AsyncSequence>: AsyncSequence {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncAdjacentPairsSequence: Sendable where Base: Sendable, Base.Element: Sendable {}

@available(*, unavailable)
Expand Down
2 changes: 2 additions & 0 deletions Sources/AsyncAlgorithms/AsyncBufferedByteIterator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
/// }
///
///
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncBufferedByteIterator: AsyncIteratorProtocol {
public typealias Element = UInt8
@usableFromInline var buffer: _AsyncBytesBuffer
Expand Down Expand Up @@ -68,6 +69,7 @@ public struct AsyncBufferedByteIterator: AsyncIteratorProtocol {
extension AsyncBufferedByteIterator: Sendable {}

@frozen @usableFromInline
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
internal struct _AsyncBytesBuffer {
@usableFromInline
final class Storage {
Expand Down
4 changes: 4 additions & 0 deletions Sources/AsyncAlgorithms/AsyncChain2Sequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
/// - Returns: An asynchronous sequence that iterates first over the elements of `s1`, and
/// then over the elements of `s2`.
@inlinable
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func chain<Base1: AsyncSequence, Base2: AsyncSequence>(
_ s1: Base1,
_ s2: Base2
Expand All @@ -27,6 +28,7 @@ public func chain<Base1: AsyncSequence, Base2: AsyncSequence>(

/// A concatenation of two asynchronous sequences with the same element type.
@frozen
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncChain2Sequence<Base1: AsyncSequence, Base2: AsyncSequence> where Base1.Element == Base2.Element {
@usableFromInline
let base1: Base1
Expand All @@ -41,6 +43,7 @@ public struct AsyncChain2Sequence<Base1: AsyncSequence, Base2: AsyncSequence> wh
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncChain2Sequence: AsyncSequence {
public typealias Element = Base1.Element

Expand Down Expand Up @@ -82,6 +85,7 @@ extension AsyncChain2Sequence: AsyncSequence {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncChain2Sequence: Sendable where Base1: Sendable, Base2: Sendable {}

@available(*, unavailable)
Expand Down
4 changes: 4 additions & 0 deletions Sources/AsyncAlgorithms/AsyncChain3Sequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/// - Returns: An asynchronous sequence that iterates first over the elements of `s1`, and
/// then over the elements of `s2`, and then over the elements of `s3`
@inlinable
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func chain<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequence>(
_ s1: Base1,
_ s2: Base2,
Expand All @@ -29,6 +30,7 @@ public func chain<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequen

/// A concatenation of three asynchronous sequences with the same element type.
@frozen
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncChain3Sequence<Base1: AsyncSequence, Base2: AsyncSequence, Base3: AsyncSequence>
where Base1.Element == Base2.Element, Base1.Element == Base3.Element {
@usableFromInline
Expand All @@ -48,6 +50,7 @@ where Base1.Element == Base2.Element, Base1.Element == Base3.Element {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncChain3Sequence: AsyncSequence {
public typealias Element = Base1.Element

Expand Down Expand Up @@ -99,6 +102,7 @@ extension AsyncChain3Sequence: AsyncSequence {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncChain3Sequence: Sendable where Base1: Sendable, Base2: Sendable, Base3: Sendable {}

@available(*, unavailable)
Expand Down
3 changes: 3 additions & 0 deletions Sources/AsyncAlgorithms/AsyncChunkedByGroupSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence {
/// Creates an asynchronous sequence that creates chunks of a given `RangeReplaceableCollection`
/// type by testing if elements belong in the same group.
Expand Down Expand Up @@ -51,6 +52,7 @@ extension AsyncSequence {
/// // [10, 20, 30]
/// // [10, 40, 40]
/// // [10, 20]
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncChunkedByGroupSequence<Base: AsyncSequence, Collected: RangeReplaceableCollection>: AsyncSequence
where Collected.Element == Base.Element {
public typealias Element = Collected
Expand Down Expand Up @@ -121,6 +123,7 @@ where Collected.Element == Base.Element {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncChunkedByGroupSequence: Sendable where Base: Sendable, Base.Element: Sendable {}

@available(*, unavailable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence {
/// Creates an asynchronous sequence that creates chunks of a given `RangeReplaceableCollection` type on the uniqueness of a given subject.
@inlinable
Expand All @@ -29,6 +30,7 @@ extension AsyncSequence {
}

/// An `AsyncSequence` that chunks on a subject when it differs from the last element.
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncChunkedOnProjectionSequence<
Base: AsyncSequence,
Subject: Equatable,
Expand Down Expand Up @@ -104,6 +106,7 @@ public struct AsyncChunkedOnProjectionSequence<
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncChunkedOnProjectionSequence: Sendable where Base: Sendable, Base.Element: Sendable {}

@available(*, unavailable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence {
/// Creates an asynchronous sequence that creates chunks of a given `RangeReplaceableCollection` type of a given count or when a signal `AsyncSequence` produces an element.
public func chunks<Signal, Collected: RangeReplaceableCollection>(
Expand Down Expand Up @@ -78,6 +79,7 @@ extension AsyncSequence {
}

/// An `AsyncSequence` that chunks elements into collected `RangeReplaceableCollection` instances by either count or a signal from another `AsyncSequence`.
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncChunksOfCountOrSignalSequence<
Base: AsyncSequence,
Collected: RangeReplaceableCollection,
Expand Down
12 changes: 10 additions & 2 deletions Sources/AsyncAlgorithms/AsyncChunksOfCountSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence {
/// Creates an asynchronous sequence that creates chunks of a given `RangeReplaceableCollection` of a given count.
@inlinable
Expand All @@ -27,6 +28,7 @@ extension AsyncSequence {
}

/// An `AsyncSequence` that chunks elements into `RangeReplaceableCollection` instances of at least a given count.
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncChunksOfCountSequence<Base: AsyncSequence, Collected: RangeReplaceableCollection>: AsyncSequence
where Collected.Element == Base.Element {
public typealias Element = Collected
Expand Down Expand Up @@ -89,8 +91,14 @@ where Collected.Element == Base.Element {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncChunksOfCountSequence: Sendable where Base: Sendable, Base.Element: Sendable {}
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncChunksOfCountSequence.Iterator: Sendable where Base.AsyncIterator: Sendable, Base.Element: Sendable {}

@available(*, unavailable)
extension AsyncChunksOfCountSequence.Iterator: Sendable {}
// The following conflicts with the above conformance. The compiler is okay with this
// when 'platforms' are specified in the package manifest but not when the @available
// attribute is used instead.
//
// @available(*, unavailable)
// extension AsyncChunksOfCountSequence.Iterator: Sendable { }
3 changes: 3 additions & 0 deletions Sources/AsyncAlgorithms/AsyncCompactedSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence {
/// Returns a new `AsyncSequence` that iterates over every non-nil element from the
/// original `AsyncSequence`.
Expand All @@ -28,6 +29,7 @@ extension AsyncSequence {
/// An `AsyncSequence` that iterates over every non-nil element from the original
/// `AsyncSequence`.
@frozen
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncCompactedSequence<Base: AsyncSequence, Element>: AsyncSequence
where Base.Element == Element? {

Expand Down Expand Up @@ -66,6 +68,7 @@ where Base.Element == Element? {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncCompactedSequence: Sendable where Base: Sendable, Base.Element: Sendable {}

@available(*, unavailable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence {
/// Returns an asynchronous sequence containing the accumulated results of combining the
/// elements of the asynchronous sequence using the given closure.
Expand Down Expand Up @@ -57,6 +58,7 @@ extension AsyncSequence {
/// An asynchronous sequence of applying a transform to the element of an asynchronous sequence and the
/// previously transformed result.
@frozen
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncExclusiveReductionsSequence<Base: AsyncSequence, Element> {
@usableFromInline
let base: Base
Expand All @@ -75,6 +77,7 @@ public struct AsyncExclusiveReductionsSequence<Base: AsyncSequence, Element> {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncExclusiveReductionsSequence: AsyncSequence {
/// The iterator for an `AsyncExclusiveReductionsSequence` instance.
@frozen
Expand Down Expand Up @@ -119,6 +122,7 @@ extension AsyncExclusiveReductionsSequence: AsyncSequence {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncExclusiveReductionsSequence: Sendable where Base: Sendable, Element: Sendable {}

@available(*, unavailable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence {
/// Returns an asynchronous sequence containing the accumulated results of combining the
/// elements of the asynchronous sequence using the given closure.
Expand Down Expand Up @@ -39,6 +40,7 @@ extension AsyncSequence {
/// An asynchronous sequence containing the accumulated results of combining the
/// elements of the asynchronous sequence using a given closure.
@frozen
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncInclusiveReductionsSequence<Base: AsyncSequence> {
@usableFromInline
let base: Base
Expand All @@ -53,6 +55,7 @@ public struct AsyncInclusiveReductionsSequence<Base: AsyncSequence> {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncInclusiveReductionsSequence: AsyncSequence {
public typealias Element = Base.Element

Expand Down Expand Up @@ -95,6 +98,7 @@ extension AsyncInclusiveReductionsSequence: AsyncSequence {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncInclusiveReductionsSequence: Sendable where Base: Sendable {}

@available(*, unavailable)
Expand Down
3 changes: 3 additions & 0 deletions Sources/AsyncAlgorithms/AsyncJoinedBySeparatorSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence where Element: AsyncSequence {
/// Concatenate an `AsyncSequence` of `AsyncSequence` elements with a separator.
@inlinable
Expand All @@ -20,6 +21,7 @@ extension AsyncSequence where Element: AsyncSequence {
}

/// An `AsyncSequence` that concatenates `AsyncSequence` elements with a separator.
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncJoinedBySeparatorSequence<Base: AsyncSequence, Separator: AsyncSequence>: AsyncSequence
where Base.Element: AsyncSequence, Separator.Element == Base.Element.Element {
public typealias Element = Base.Element.Element
Expand Down Expand Up @@ -143,6 +145,7 @@ where Base.Element: AsyncSequence, Separator.Element == Base.Element.Element {
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncJoinedBySeparatorSequence: Sendable
where Base: Sendable, Base.Element: Sendable, Base.Element.Element: Sendable, Separator: Sendable {}

Expand Down
3 changes: 3 additions & 0 deletions Sources/AsyncAlgorithms/AsyncJoinedSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncSequence where Element: AsyncSequence {
/// Concatenate an `AsyncSequence` of `AsyncSequence` elements
@inlinable
Expand All @@ -19,6 +20,7 @@ extension AsyncSequence where Element: AsyncSequence {

/// An `AsyncSequence` that concatenates`AsyncSequence` elements
@frozen
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public struct AsyncJoinedSequence<Base: AsyncSequence>: AsyncSequence where Base.Element: AsyncSequence {
public typealias Element = Base.Element.Element
public typealias AsyncIterator = Iterator
Expand Down Expand Up @@ -90,6 +92,7 @@ public struct AsyncJoinedSequence<Base: AsyncSequence>: AsyncSequence where Base
}
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension AsyncJoinedSequence: Sendable
where Base: Sendable, Base.Element: Sendable, Base.Element.Element: Sendable {}

Expand Down
Loading
Loading