Skip to content

Commit

Permalink
Merge pull request #38 from gwynne/patch-1
Browse files Browse the repository at this point in the history
Stop using opaque return types to resolve build error
  • Loading branch information
guoye-zhang authored Dec 2, 2023
2 parents 4c54209 + fee4574 commit 1827dc9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
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

0 comments on commit 1827dc9

Please sign in to comment.