Skip to content

Commit e8f694e

Browse files
committed
Adjust to changes in swift-format's rules
The changes were introduced from upgrading Xcode from 16.2 to 16.3, which upgraded the Swift compiler from 6.0 to 6.1.
1 parent 6828d41 commit e8f694e

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed

Sources/EmbeddedIntegerCollection/EmbeddedIntegerCollection.swift

+9-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ where
6969
iteratingFrom bitRange: EmbeddedIteratorDirection
7070
) {
7171
self.init(
72-
within: Wrapped(element) &* Self.allEmbeddedOnes, iteratingFrom: bitRange
72+
within: Wrapped(element) &* Self.allEmbeddedOnes,
73+
iteratingFrom: bitRange
7374
)
7475
}
7576
}
@@ -345,7 +346,8 @@ public struct EmbeddedIntegerCollectionIndices: RandomAccessCollection {
345346
// Do `i + distance * stride` in a way that doesn't trap overflow.
346347
guard
347348
case let (bitDistance, overflow1) = distance.multipliedReportingOverflow(
348-
by: stride),
349+
by: stride
350+
),
349351
case let (rawResult, overflow2) = i.addingReportingOverflow(bitDistance),
350352
!overflow1 && !overflow2
351353
else {
@@ -372,7 +374,8 @@ public struct EmbeddedIntegerCollectionIndices: RandomAccessCollection {
372374

373375
public func _copyToContiguousArray() -> ContiguousArray<Int> {
374376
return .init(unsafeUninitializedCapacity: count) {
375-
buffer, initializedCount in
377+
buffer,
378+
initializedCount in
376379
for (sourceIndex, bufferIndex) in zip(indices, buffer.indices) {
377380
buffer.initializeElement(at: bufferIndex, to: sourceIndex)
378381
initializedCount += 1
@@ -490,7 +493,9 @@ extension EmbeddedIntegerCollection {
490493
) {
491494
var iterator = sequence.makeIterator()
492495
self.init(
493-
extractingFrom: &iterator, embeddingInto: type, fillingFrom: bitRange
496+
extractingFrom: &iterator,
497+
embeddingInto: type,
498+
fillingFrom: bitRange
494499
)
495500
guard !readAll || iterator.next() == nil else { return nil }
496501
}

Tests/EmbeddedIntegerCollectionTests/EmbeddedIntegerCollectionTests.swift

+36-17
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ func debugPrint(_ input: (base: UInt64, isBigEndian: Bool), expected: String)
2323
async throws
2424
{
2525
let collection = EmbeddedIntegerCollection(
26-
embedding: UInt16.self, within: input.base,
26+
embedding: UInt16.self,
27+
within: input.base,
2728
iteratingFrom: input.isBigEndian
2829
? .mostSignificantFirst
2930
: .leastSignificantFirst
@@ -36,19 +37,27 @@ func debugPrint(_ input: (base: UInt64, isBigEndian: Bool), expected: String)
3637
@Test("Repeating-element initializer")
3738
func repeatingInitializer() async throws {
3839
let collection1 = EmbeddedIntegerCollection.init(
39-
repeating: 0 as UInt16, embeddedIn: UInt64.self,
40-
iteratingFrom: .mostSignificantFirst)
40+
repeating: 0 as UInt16,
41+
embeddedIn: UInt64.self,
42+
iteratingFrom: .mostSignificantFirst
43+
)
4144
let collection2 = EmbeddedIntegerCollection(
42-
embedding: UInt16.self, within: 0 as UInt64,
43-
iteratingFrom: .mostSignificantFirst)
45+
embedding: UInt16.self,
46+
within: 0 as UInt64,
47+
iteratingFrom: .mostSignificantFirst
48+
)
4449
#expect(collection1 == collection2)
4550

4651
let collection3 = EmbeddedIntegerCollection(
47-
embedding: UInt8.self, within: 0x6F6F_6F6F as UInt32,
48-
iteratingFrom: .leastSignificantFirst)
52+
embedding: UInt8.self,
53+
within: 0x6F6F_6F6F as UInt32,
54+
iteratingFrom: .leastSignificantFirst
55+
)
4956
let collection4 = EmbeddedIntegerCollection(
50-
repeating: 0x6F as UInt8, embeddedIn: UInt32.self,
51-
iteratingFrom: .leastSignificantFirst)
57+
repeating: 0x6F as UInt8,
58+
embeddedIn: UInt32.self,
59+
iteratingFrom: .leastSignificantFirst
60+
)
5261
#expect(collection3 == collection4)
5362
}
5463

@@ -66,11 +75,13 @@ func repeatingInitializer() async throws {
6675
)
6776
)
6877
func basicCollections(
69-
_ input: (base: UInt32, isBigEndian: Bool), expected: [UInt8]
78+
_ input: (base: UInt32, isBigEndian: Bool),
79+
expected: [UInt8]
7080
) async throws {
7181
// Sequence (and indirectly Collection)
7282
var collection = EmbeddedIntegerCollection(
73-
embedding: UInt8.self, within: input.base,
83+
embedding: UInt8.self,
84+
within: input.base,
7485
iteratingFrom: input.isBigEndian
7586
? .mostSignificantFirst
7687
: .leastSignificantFirst
@@ -143,7 +154,9 @@ func basicCollections(
143154
func moreIndexChecks(_ startingBitRange: EmbeddedIteratorDirection) async throws
144155
{
145156
let collection = EmbeddedIntegerCollection(
146-
embedding: UInt8.self, within: 0 as UInt64, iteratingFrom: startingBitRange
157+
embedding: UInt8.self,
158+
within: 0 as UInt64,
159+
iteratingFrom: startingBitRange
147160
)
148161
let collectionIndices = collection.indices
149162

@@ -177,7 +190,9 @@ func moreIndexChecks(_ startingBitRange: EmbeddedIteratorDirection) async throws
177190
// Over-sized distances
178191
#expect(
179192
collection.index(
180-
goodIndex, offsetBy: .max, limitedBy: collection.endIndex
193+
goodIndex,
194+
offsetBy: .max,
195+
limitedBy: collection.endIndex
181196
) == nil
182197
)
183198

@@ -317,7 +332,8 @@ func normalPrint(_ input: (base: UInt32, isBigEndian: Bool), expected: String)
317332
func mutateContiguousStorage() async throws {
318333
// No usage with elements aren't raw octets.
319334
var nonOctets = EmbeddedIntegerCollection(
320-
embedding: UInt16.self, within: 0x1234_5678_9ABC_DEF0 as UInt64,
335+
embedding: UInt16.self,
336+
within: 0x1234_5678_9ABC_DEF0 as UInt64,
321337
iteratingFrom: .mostSignificantFirst
322338
)
323339
let nonOctetCount = nonOctets.withContiguousMutableStorageIfAvailable(
@@ -327,7 +343,8 @@ func mutateContiguousStorage() async throws {
327343

328344
// Octet elements
329345
var bigOctets = EmbeddedIntegerCollection(
330-
embedding: UInt8.self, within: 0x0123_4567 as UInt32,
346+
embedding: UInt8.self,
347+
within: 0x0123_4567 as UInt32,
331348
iteratingFrom: .mostSignificantFirst
332349
)
333350
#expect(bigOctets.word == 0x0123_4567)
@@ -341,7 +358,8 @@ func mutateContiguousStorage() async throws {
341358
#expect(bigOctets.elementsEqual([0xFE, 0xDC, 0xBA, 0x98]))
342359

343360
var littleOctets = EmbeddedIntegerCollection(
344-
embedding: UInt8.self, within: 0x0123_4567 as UInt32,
361+
embedding: UInt8.self,
362+
within: 0x0123_4567 as UInt32,
345363
iteratingFrom: .leastSignificantFirst
346364
)
347365
#expect(littleOctets.word == 0x0123_4567)
@@ -366,7 +384,8 @@ where T.Element: BinaryInteger {
366384

367385
@Test(
368386
"Inspect contiguous storage",
369-
arguments: [0, 0x0123_4567, 0x89AB_CDEF], [false, true]
387+
arguments: [0, 0x0123_4567, 0x89AB_CDEF],
388+
[false, true]
370389
)
371390
func inspectContiguousStorage(wrapped: UInt32, isBigEndian: Bool) async throws {
372391
let collection = EmbeddedIntegerCollection(

0 commit comments

Comments
 (0)