Skip to content

Commit 28a5f3a

Browse files
committed
Per PR discussion, remove platform specifiers and discontinue use of some rather than forcing other packages to change their manifests.
1 parent f98bb56 commit 28a5f3a

File tree

6 files changed

+27
-33
lines changed

6 files changed

+27
-33
lines changed

Package.swift

-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ import PackageDescription
44

55
let package = Package(
66
name: "swift-http-types",
7-
platforms: [
8-
.macOS("10.15"),
9-
.iOS("13.0"),
10-
.watchOS("6.0"),
11-
.tvOS("13.0"),
12-
],
137
products: [
148
.library(name: "HTTPTypes", targets: ["HTTPTypes"]),
159
.library(name: "HTTPTypesFoundation", targets: ["HTTPTypesFoundation"]),

Sources/HTTPTypes/HTTPField.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public struct HTTPField: Sendable, Hashable {
6363
/// - Parameters:
6464
/// - name: The HTTP field name.
6565
/// - value: The HTTP field value. Invalid bytes are converted into space characters.
66-
public init(name: Name, value: some Collection<UInt8>) {
66+
public init<C: Collection>(name: Name, value: C) where C.Element == UInt8 {
6767
self.name = name
6868
self.rawValue = Self.legalizeValue(ISOLatin1String(value))
6969
}
@@ -111,7 +111,7 @@ public struct HTTPField: Sendable, Hashable {
111111

112112
var rawValue: ISOLatin1String
113113

114-
private static func _isValidValue(_ bytes: some Sequence<UInt8>) -> Bool {
114+
private static func _isValidValue<S: Sequence>(_ bytes: S) -> Bool where S.Element == UInt8 {
115115
var iterator = bytes.makeIterator()
116116
guard var byte = iterator.next() else {
117117
// Empty string is allowed.
@@ -178,7 +178,7 @@ public struct HTTPField: Sendable, Hashable {
178178
///
179179
/// - Parameter value: The byte collection to validate.
180180
/// - Returns: Whether the byte collection is valid.
181-
public static func isValidValue(_ value: some Collection<UInt8>) -> Bool {
181+
public static func isValidValue<C: Collection>(_ value: C) -> Bool where C.Element == UInt8 {
182182
self._isValidValue(value)
183183
}
184184
}
@@ -227,7 +227,7 @@ extension HTTPField: Codable {
227227
}
228228

229229
extension HTTPField {
230-
static func isValidToken(_ token: some StringProtocol) -> Bool {
230+
static func isValidToken<S: StringProtocol>(_ token: S) -> Bool {
231231
!token.isEmpty && token.utf8.allSatisfy {
232232
switch $0 {
233233
case 0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2A, 0x2B, 0x2D, 0x2E, 0x5E, 0x5F, 0x60, 0x7C, 0x7E:

Sources/HTTPTypes/HTTPFields.swift

+19-19
Original file line numberDiff line numberDiff line change
@@ -216,35 +216,35 @@ public struct HTTPFields: Sendable, Hashable {
216216
}
217217
}
218218

219-
private func fields(for name: HTTPField.Name) -> some Sequence<HTTPField> {
220-
struct HTTPFieldSequence: Sequence {
221-
let fields: [(field: HTTPField, next: UInt16)]
222-
let index: UInt16
219+
private struct HTTPFieldSequence: Sequence {
220+
let fields: [(field: HTTPField, next: UInt16)]
221+
let index: UInt16
223222

224-
struct Iterator: IteratorProtocol {
225-
let fields: [(field: HTTPField, next: UInt16)]
226-
var index: UInt16
223+
struct Iterator: IteratorProtocol {
224+
let fields: [(field: HTTPField, next: UInt16)]
225+
var index: UInt16
227226

228-
mutating func next() -> HTTPField? {
229-
if self.index == .max {
230-
return nil
231-
}
232-
let (field, next) = self.fields[Int(self.index)]
233-
self.index = next
234-
return field
227+
mutating func next() -> HTTPField? {
228+
if self.index == .max {
229+
return nil
235230
}
231+
let (field, next) = self.fields[Int(self.index)]
232+
self.index = next
233+
return field
236234
}
235+
}
237236

238-
func makeIterator() -> Iterator {
239-
Iterator(fields: self.fields, index: self.index)
240-
}
237+
func makeIterator() -> Iterator {
238+
Iterator(fields: self.fields, index: self.index)
241239
}
240+
}
242241

242+
private func fields(for name: HTTPField.Name) -> HTTPFieldSequence {
243243
let index = self._storage.ensureIndex[name.canonicalName]?.first ?? .max
244244
return HTTPFieldSequence(fields: self._storage.fields, index: index)
245245
}
246246

247-
private mutating func setFields(_ fieldSequence: some Sequence<HTTPField>, for name: HTTPField.Name) {
247+
private mutating func setFields<S: Sequence>(_ fieldSequence: S, for name: HTTPField.Name) where S.Element == HTTPField {
248248
if !isKnownUniquelyReferenced(&self._storage) {
249249
self._storage = self._storage.copy()
250250
}
@@ -384,7 +384,7 @@ extension HTTPFields: Codable {
384384

385385
extension Array {
386386
// `removalIndices` must be ordered.
387-
mutating func remove(at removalIndices: some Sequence<Index>) {
387+
mutating func remove<S: Sequence>(at removalIndices: S) where S.Element == Index {
388388
var offset = 0
389389
var iterator = removalIndices.makeIterator()
390390
var nextToRemoveOptional = iterator.next()

Sources/HTTPTypes/ISOLatin1String.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extension String {
2121
struct ISOLatin1String: Sendable, Hashable {
2222
let _storage: String
2323

24-
private static func transcodeSlowPath(from bytes: some Collection<UInt8>) -> String {
24+
private static func transcodeSlowPath<C: Collection>(from bytes: C) -> String where C.Element == UInt8 {
2525
let scalars = bytes.lazy.map { UnicodeScalar(UInt32($0))! }
2626
var string = ""
2727
string.unicodeScalars.append(contentsOf: scalars)
@@ -46,7 +46,7 @@ struct ISOLatin1String: Sendable, Hashable {
4646
}
4747
}
4848

49-
init(_ bytes: some Collection<UInt8>) {
49+
init<C: Collection>(_ bytes: C) where C.Element == UInt8 {
5050
let ascii = bytes.allSatisfy { $0 & 0x80 == 0 }
5151
if ascii {
5252
self._storage = String(decoding: bytes, as: UTF8.self)

Sources/HTTPTypesFoundation/HTTPRequest+URL.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extension HTTPRequest {
6565
}
6666

6767
extension URL {
68-
fileprivate init?(scheme: some Collection<UInt8>, authority: some Collection<UInt8>, path: some Collection<UInt8>) {
68+
fileprivate init?<C1: Collection, C2: Collection, C3: Collection>(scheme: C1, authority: C2, path: C3) where C1.Element == UInt8, C2.Element == UInt8, C3.Element == UInt8 {
6969
var buffer = [UInt8]()
7070
buffer.reserveCapacity(scheme.count + 3 + authority.count + path.count)
7171
buffer.append(contentsOf: scheme)

Tests/HTTPTypesTests/HTTPTypesTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ final class HTTPTypesTests: XCTestCase {
117117
}
118118

119119
func testSendable() {
120-
func isSendable(_ value: some Sendable) -> Bool { true }
120+
func isSendable<T: Sendable>(_ value: T) -> Bool { true }
121121
func isSendable(_ value: Any) -> Bool { false }
122122

123123
let field: HTTPField = .init(name: .userAgent, value: "")

0 commit comments

Comments
 (0)