Skip to content
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

Stop using opaque return types to resolve build error #38

Merged
merged 3 commits into from
Dec 2, 2023
Merged
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
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ needs to be listed here.

- Franz Busch <[email protected]>
- Guoye Zhang <[email protected]>
- Gwynne Raskind <[email protected]>
- Jager-yoo <[email protected]>
- Sergey Dmitriev <[email protected]>
- Tim Condon <[email protected]>
- Tomohiro Kumagai <[email protected]>

**Updating this list**
Expand Down
34 changes: 17 additions & 17 deletions Sources/HTTPTypes/HTTPFields.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,30 +216,30 @@ public struct HTTPFields: Sendable, Hashable {
}
}

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

struct Iterator: IteratorProtocol {
let fields: [(field: HTTPField, next: UInt16)]
var index: UInt16
struct Iterator: IteratorProtocol {
let fields: [(field: HTTPField, next: UInt16)]
var index: UInt16

mutating func next() -> HTTPField? {
if self.index == .max {
return nil
}
let (field, next) = self.fields[Int(self.index)]
self.index = next
return field
mutating func next() -> HTTPField? {
if self.index == .max {
return nil
}
let (field, next) = self.fields[Int(self.index)]
self.index = next
return field
}
}

func makeIterator() -> Iterator {
Iterator(fields: self.fields, index: self.index)
}
func makeIterator() -> Iterator {
Iterator(fields: self.fields, index: self.index)
}
}

private func fields(for name: HTTPField.Name) -> HTTPFieldSequence {
let index = self._storage.ensureIndex[name.canonicalName]?.first ?? .max
return HTTPFieldSequence(fields: self._storage.fields, index: index)
}
Expand Down