mirror of
https://github.com/apple/swift-http-structured-headers
synced 2026-11-26 04:57:47 +00:00
fix formatting so that sanity script passes (#7)
* fix formatting so that sanity script passes motivation: consistent formatting as prep for OSS changes: run swiftformat to align formatting * dont use TSAN on 18.04
This commit is contained in:
1 parent
0fa022ed66
commit
dd9aca3533
7 files changed
+24
-26
No files matched your search
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
@@ -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]
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user