Skip to content

Commit fee4574

Browse files
committed
Revert argument changes
1 parent 28a5f3a commit fee4574

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

CONTRIBUTORS.txt

+2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ needs to be listed here.
1313

1414
- Franz Busch <[email protected]>
1515
- Guoye Zhang <[email protected]>
16+
- Gwynne Raskind <[email protected]>
1617
- Jager-yoo <[email protected]>
1718
- Sergey Dmitriev <[email protected]>
19+
- Tim Condon <[email protected]>
1820
- Tomohiro Kumagai <[email protected]>
1921

2022
**Updating this list**

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<C: Collection>(name: Name, value: C) where C.Element == UInt8 {
66+
public init(name: Name, value: some Collection<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<S: Sequence>(_ bytes: S) -> Bool where S.Element == UInt8 {
114+
private static func _isValidValue(_ bytes: some Sequence<UInt8>) -> Bool {
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<C: Collection>(_ value: C) -> Bool where C.Element == UInt8 {
181+
public static func isValidValue(_ value: some Collection<UInt8>) -> Bool {
182182
self._isValidValue(value)
183183
}
184184
}
@@ -227,7 +227,7 @@ extension HTTPField: Codable {
227227
}
228228

229229
extension HTTPField {
230-
static func isValidToken<S: StringProtocol>(_ token: S) -> Bool {
230+
static func isValidToken(_ token: some StringProtocol) -> 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

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public struct HTTPFields: Sendable, Hashable {
244244
return HTTPFieldSequence(fields: self._storage.fields, index: index)
245245
}
246246

247-
private mutating func setFields<S: Sequence>(_ fieldSequence: S, for name: HTTPField.Name) where S.Element == HTTPField {
247+
private mutating func setFields(_ fieldSequence: some Sequence<HTTPField>, for name: HTTPField.Name) {
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<S: Sequence>(at removalIndices: S) where S.Element == Index {
387+
mutating func remove(at removalIndices: some Sequence<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<C: Collection>(from bytes: C) -> String where C.Element == UInt8 {
24+
private static func transcodeSlowPath(from bytes: some Collection<UInt8>) -> String {
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<C: Collection>(_ bytes: C) where C.Element == UInt8 {
49+
init(_ bytes: some Collection<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?<C1: Collection, C2: Collection, C3: Collection>(scheme: C1, authority: C2, path: C3) where C1.Element == UInt8, C2.Element == UInt8, C3.Element == UInt8 {
68+
fileprivate init?(scheme: some Collection<UInt8>, authority: some Collection<UInt8>, path: some Collection<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<T: Sendable>(_ value: T) -> Bool { true }
120+
func isSendable(_ value: some Sendable) -> Bool { true }
121121
func isSendable(_ value: Any) -> Bool { false }
122122

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

0 commit comments

Comments
 (0)