Skip to content

fix formatting so that sanity script passes #7

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

Merged
merged 2 commits into from
Jan 15, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct KeyedTopLevelListDecoder<Key: CodingKey, BaseData: RandomAccessCollection
private var list: [ItemOrInnerList]

private var decoder: _StructuredFieldDecoder<BaseData>

init(_ list: [ItemOrInnerList], decoder: _StructuredFieldDecoder<BaseData>) {
self.list = list
self.decoder = decoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public protocol StructuredHeaderField: Codable {
static var structuredFieldType: StructuredHeaderFieldType { get }
}


/// The kinds of header fields used in HTTP Structured Headers.
public enum StructuredHeaderFieldType {
/// An item field consists of a single item, optionally with parameters.
Expand Down
34 changes: 17 additions & 17 deletions Sources/StructuredHeaders/FieldParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -523,24 +523,24 @@ extension String {
// `StrippingStringEscapesCollection` for more details on what we're doing here.
let unescapedBytes = StrippingStringEscapesCollection(bytes, escapes: escapes)
#if canImport(Darwin)
if #available(macOS 10.16, macCatalyst 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
return endIndex
}
} else {
return String(decoding: unescapedBytes, as: UTF8.self)
if #available(macOS 10.16, macCatalyst 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
return endIndex
}
#else
#if compiler(>=5.3)
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
return endIndex
}
#else
return String(decoding: unescapedBytes, as: UTF8.self)
#endif
#endif
} else {
return String(decoding: unescapedBytes, as: UTF8.self)
}
#else
#if compiler(>=5.3)
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
return endIndex
}
#else
return String(decoding: unescapedBytes, as: UTF8.self)
#endif
#endif
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/StructuredHeaders/FieldSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ extension StructuredFieldSerializer {
self.data.append(contentsOf: key.utf8)
}

private mutating func serializeABareItem(_ item: BareItem) throws{
private mutating func serializeABareItem(_ item: BareItem) throws {
switch item {
case .integer(let int):
guard let wideInt = Int64(exactly: int), validIntegerRange.contains(wideInt) else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct ListyDictionaryParameterisedList: Codable, Equatable {

struct ItemField<Base: Codable & Equatable>: StructuredHeaderField, Equatable {
static var structuredFieldType: StructuredHeaderFieldType {
return .item
.item
}

var item: Base
Expand All @@ -45,7 +45,7 @@ struct ItemField<Base: Codable & Equatable>: StructuredHeaderField, Equatable {

struct List<Base: Codable & Equatable>: StructuredHeaderField, Equatable {
static var structuredFieldType: StructuredHeaderFieldType {
return .list
.list
}

var items: [Base]
Expand All @@ -57,7 +57,7 @@ struct List<Base: Codable & Equatable>: StructuredHeaderField, Equatable {

struct DictionaryField<Key: Codable & Hashable, Value: Codable & Equatable>: StructuredHeaderField, Equatable {
static var structuredFieldType: StructuredHeaderFieldType {
return .dictionary
.dictionary
}

var items: [Key: Value]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ final class StructuredFieldEncoderTests: XCTestCase {
func testEncodeKeyedItemHeader() throws {
struct KeyedItem<ItemType: Codable & Equatable>: Equatable, StructuredHeaderField {
static var structuredFieldType: StructuredHeaderFieldType {
return .item
.item
}

var item: ItemType
var parameters: [String: Bool]
}
Expand Down
2 changes: 0 additions & 2 deletions docker/docker-compose.1804.53.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ services:

test:
image: swift-http-structured-headers:18.04-5.3
environment:
- SANITIZER_ARG=--sanitize=thread

shell:
image: swift-http-structured-headers:18.04-5.3
Expand Down