@@ -65,7 +65,10 @@ public struct TupleExprElementList: ExpressibleByArrayLiteral, SyntaxBuildable,
65
65
/// - Parameters:
66
66
/// - elements: A list of `ExpressibleAsTupleExprElement`
67
67
public init ( _ elements: [ ExpressibleAsTupleExprElement ] ) {
68
- self . elements = elements. map { $0. createTupleExprElement ( ) }
68
+ let lastIndex = elements. count - 1
69
+ self . elements = elements. enumerated ( ) . map ( { index, element in
70
+ element. createTupleExprElement ( ) . withTrailingComma ( index < lastIndex)
71
+ } )
69
72
}
70
73
71
74
public init ( arrayLiteral elements: ExpressibleAsTupleExprElement ... ) {
@@ -108,7 +111,10 @@ public struct ArrayElementList: ExpressibleByArrayLiteral, SyntaxBuildable, Expr
108
111
/// - Parameters:
109
112
/// - elements: A list of `ExpressibleAsArrayElement`
110
113
public init ( _ elements: [ ExpressibleAsArrayElement ] ) {
111
- self . elements = elements. map { $0. createArrayElement ( ) }
114
+ let lastIndex = elements. count - 1
115
+ self . elements = elements. enumerated ( ) . map ( { index, element in
116
+ element. createArrayElement ( ) . withTrailingComma ( index < lastIndex)
117
+ } )
112
118
}
113
119
114
120
public init ( arrayLiteral elements: ExpressibleAsArrayElement ... ) {
@@ -151,7 +157,10 @@ public struct DictionaryElementList: ExpressibleByArrayLiteral, SyntaxBuildable,
151
157
/// - Parameters:
152
158
/// - elements: A list of `ExpressibleAsDictionaryElement`
153
159
public init ( _ elements: [ ExpressibleAsDictionaryElement ] ) {
154
- self . elements = elements. map { $0. createDictionaryElement ( ) }
160
+ let lastIndex = elements. count - 1
161
+ self . elements = elements. enumerated ( ) . map ( { index, element in
162
+ element. createDictionaryElement ( ) . withTrailingComma ( index < lastIndex)
163
+ } )
155
164
}
156
165
157
166
public init ( arrayLiteral elements: ExpressibleAsDictionaryElement ... ) {
@@ -323,7 +332,10 @@ public struct ClosureCaptureItemList: ExpressibleByArrayLiteral, SyntaxBuildable
323
332
/// - Parameters:
324
333
/// - elements: A list of `ExpressibleAsClosureCaptureItem`
325
334
public init ( _ elements: [ ExpressibleAsClosureCaptureItem ] ) {
326
- self . elements = elements. map { $0. createClosureCaptureItem ( ) }
335
+ let lastIndex = elements. count - 1
336
+ self . elements = elements. enumerated ( ) . map ( { index, element in
337
+ element. createClosureCaptureItem ( ) . withTrailingComma ( index < lastIndex)
338
+ } )
327
339
}
328
340
329
341
public init ( arrayLiteral elements: ExpressibleAsClosureCaptureItem ... ) {
@@ -366,7 +378,10 @@ public struct ClosureParamList: ExpressibleByArrayLiteral, SyntaxBuildable, Expr
366
378
/// - Parameters:
367
379
/// - elements: A list of `ExpressibleAsClosureParam`
368
380
public init ( _ elements: [ ExpressibleAsClosureParam ] ) {
369
- self . elements = elements. map { $0. createClosureParam ( ) }
381
+ let lastIndex = elements. count - 1
382
+ self . elements = elements. enumerated ( ) . map ( { index, element in
383
+ element. createClosureParam ( ) . withTrailingComma ( index < lastIndex)
384
+ } )
370
385
}
371
386
372
387
public init ( arrayLiteral elements: ExpressibleAsClosureParam ... ) {
@@ -495,7 +510,10 @@ public struct FunctionParameterList: ExpressibleByArrayLiteral, SyntaxBuildable,
495
510
/// - Parameters:
496
511
/// - elements: A list of `ExpressibleAsFunctionParameter`
497
512
public init ( _ elements: [ ExpressibleAsFunctionParameter ] ) {
498
- self . elements = elements. map { $0. createFunctionParameter ( ) }
513
+ let lastIndex = elements. count - 1
514
+ self . elements = elements. enumerated ( ) . map ( { index, element in
515
+ element. createFunctionParameter ( ) . withTrailingComma ( index < lastIndex)
516
+ } )
499
517
}
500
518
501
519
public init ( arrayLiteral elements: ExpressibleAsFunctionParameter ... ) {
@@ -581,7 +599,10 @@ public struct InheritedTypeList: ExpressibleByArrayLiteral, SyntaxBuildable, Exp
581
599
/// - Parameters:
582
600
/// - elements: A list of `ExpressibleAsInheritedType`
583
601
public init ( _ elements: [ ExpressibleAsInheritedType ] ) {
584
- self . elements = elements. map { $0. createInheritedType ( ) }
602
+ let lastIndex = elements. count - 1
603
+ self . elements = elements. enumerated ( ) . map ( { index, element in
604
+ element. createInheritedType ( ) . withTrailingComma ( index < lastIndex)
605
+ } )
585
606
}
586
607
587
608
public init ( arrayLiteral elements: ExpressibleAsInheritedType ... ) {
@@ -796,7 +817,10 @@ public struct PatternBindingList: ExpressibleByArrayLiteral, SyntaxBuildable, Ex
796
817
/// - Parameters:
797
818
/// - elements: A list of `ExpressibleAsPatternBinding`
798
819
public init ( _ elements: [ ExpressibleAsPatternBinding ] ) {
799
- self . elements = elements. map { $0. createPatternBinding ( ) }
820
+ let lastIndex = elements. count - 1
821
+ self . elements = elements. enumerated ( ) . map ( { index, element in
822
+ element. createPatternBinding ( ) . withTrailingComma ( index < lastIndex)
823
+ } )
800
824
}
801
825
802
826
public init ( arrayLiteral elements: ExpressibleAsPatternBinding ... ) {
@@ -839,7 +863,10 @@ public struct EnumCaseElementList: ExpressibleByArrayLiteral, SyntaxBuildable, E
839
863
/// - Parameters:
840
864
/// - elements: A list of `ExpressibleAsEnumCaseElement`
841
865
public init ( _ elements: [ ExpressibleAsEnumCaseElement ] ) {
842
- self . elements = elements. map { $0. createEnumCaseElement ( ) }
866
+ let lastIndex = elements. count - 1
867
+ self . elements = elements. enumerated ( ) . map ( { index, element in
868
+ element. createEnumCaseElement ( ) . withTrailingComma ( index < lastIndex)
869
+ } )
843
870
}
844
871
845
872
public init ( arrayLiteral elements: ExpressibleAsEnumCaseElement ... ) {
@@ -1220,7 +1247,10 @@ public struct DifferentiabilityParamList: ExpressibleByArrayLiteral, SyntaxBuild
1220
1247
/// - Parameters:
1221
1248
/// - elements: A list of `ExpressibleAsDifferentiabilityParam`
1222
1249
public init ( _ elements: [ ExpressibleAsDifferentiabilityParam ] ) {
1223
- self . elements = elements. map { $0. createDifferentiabilityParam ( ) }
1250
+ let lastIndex = elements. count - 1
1251
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1252
+ element. createDifferentiabilityParam ( ) . withTrailingComma ( index < lastIndex)
1253
+ } )
1224
1254
}
1225
1255
1226
1256
public init ( arrayLiteral elements: ExpressibleAsDifferentiabilityParam ... ) {
@@ -1392,7 +1422,10 @@ public struct CaseItemList: ExpressibleByArrayLiteral, SyntaxBuildable, Expressi
1392
1422
/// - Parameters:
1393
1423
/// - elements: A list of `ExpressibleAsCaseItem`
1394
1424
public init ( _ elements: [ ExpressibleAsCaseItem ] ) {
1395
- self . elements = elements. map { $0. createCaseItem ( ) }
1425
+ let lastIndex = elements. count - 1
1426
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1427
+ element. createCaseItem ( ) . withTrailingComma ( index < lastIndex)
1428
+ } )
1396
1429
}
1397
1430
1398
1431
public init ( arrayLiteral elements: ExpressibleAsCaseItem ... ) {
@@ -1435,7 +1468,10 @@ public struct CatchItemList: ExpressibleByArrayLiteral, SyntaxBuildable, Express
1435
1468
/// - Parameters:
1436
1469
/// - elements: A list of `ExpressibleAsCatchItem`
1437
1470
public init ( _ elements: [ ExpressibleAsCatchItem ] ) {
1438
- self . elements = elements. map { $0. createCatchItem ( ) }
1471
+ let lastIndex = elements. count - 1
1472
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1473
+ element. createCatchItem ( ) . withTrailingComma ( index < lastIndex)
1474
+ } )
1439
1475
}
1440
1476
1441
1477
public init ( arrayLiteral elements: ExpressibleAsCatchItem ... ) {
@@ -1478,7 +1514,10 @@ public struct ConditionElementList: ExpressibleByArrayLiteral, SyntaxBuildable,
1478
1514
/// - Parameters:
1479
1515
/// - elements: A list of `ExpressibleAsConditionElement`
1480
1516
public init ( _ elements: [ ExpressibleAsConditionElement ] ) {
1481
- self . elements = elements. map { $0. createConditionElement ( ) }
1517
+ let lastIndex = elements. count - 1
1518
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1519
+ element. createConditionElement ( ) . withTrailingComma ( index < lastIndex)
1520
+ } )
1482
1521
}
1483
1522
1484
1523
public init ( arrayLiteral elements: ExpressibleAsConditionElement ... ) {
@@ -1521,7 +1560,10 @@ public struct GenericRequirementList: ExpressibleByArrayLiteral, SyntaxBuildable
1521
1560
/// - Parameters:
1522
1561
/// - elements: A list of `ExpressibleAsGenericRequirement`
1523
1562
public init ( _ elements: [ ExpressibleAsGenericRequirement ] ) {
1524
- self . elements = elements. map { $0. createGenericRequirement ( ) }
1563
+ let lastIndex = elements. count - 1
1564
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1565
+ element. createGenericRequirement ( ) . withTrailingComma ( index < lastIndex)
1566
+ } )
1525
1567
}
1526
1568
1527
1569
public init ( arrayLiteral elements: ExpressibleAsGenericRequirement ... ) {
@@ -1564,7 +1606,10 @@ public struct GenericParameterList: ExpressibleByArrayLiteral, SyntaxBuildable,
1564
1606
/// - Parameters:
1565
1607
/// - elements: A list of `ExpressibleAsGenericParameter`
1566
1608
public init ( _ elements: [ ExpressibleAsGenericParameter ] ) {
1567
- self . elements = elements. map { $0. createGenericParameter ( ) }
1609
+ let lastIndex = elements. count - 1
1610
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1611
+ element. createGenericParameter ( ) . withTrailingComma ( index < lastIndex)
1612
+ } )
1568
1613
}
1569
1614
1570
1615
public init ( arrayLiteral elements: ExpressibleAsGenericParameter ... ) {
@@ -1607,7 +1652,10 @@ public struct PrimaryAssociatedTypeList: ExpressibleByArrayLiteral, SyntaxBuilda
1607
1652
/// - Parameters:
1608
1653
/// - elements: A list of `ExpressibleAsPrimaryAssociatedType`
1609
1654
public init ( _ elements: [ ExpressibleAsPrimaryAssociatedType ] ) {
1610
- self . elements = elements. map { $0. createPrimaryAssociatedType ( ) }
1655
+ let lastIndex = elements. count - 1
1656
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1657
+ element. createPrimaryAssociatedType ( ) . withTrailingComma ( index < lastIndex)
1658
+ } )
1611
1659
}
1612
1660
1613
1661
public init ( arrayLiteral elements: ExpressibleAsPrimaryAssociatedType ... ) {
@@ -1693,7 +1741,10 @@ public struct TupleTypeElementList: ExpressibleByArrayLiteral, SyntaxBuildable,
1693
1741
/// - Parameters:
1694
1742
/// - elements: A list of `ExpressibleAsTupleTypeElement`
1695
1743
public init ( _ elements: [ ExpressibleAsTupleTypeElement ] ) {
1696
- self . elements = elements. map { $0. createTupleTypeElement ( ) }
1744
+ let lastIndex = elements. count - 1
1745
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1746
+ element. createTupleTypeElement ( ) . withTrailingComma ( index < lastIndex)
1747
+ } )
1697
1748
}
1698
1749
1699
1750
public init ( arrayLiteral elements: ExpressibleAsTupleTypeElement ... ) {
@@ -1736,7 +1787,10 @@ public struct GenericArgumentList: ExpressibleByArrayLiteral, SyntaxBuildable, E
1736
1787
/// - Parameters:
1737
1788
/// - elements: A list of `ExpressibleAsGenericArgument`
1738
1789
public init ( _ elements: [ ExpressibleAsGenericArgument ] ) {
1739
- self . elements = elements. map { $0. createGenericArgument ( ) }
1790
+ let lastIndex = elements. count - 1
1791
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1792
+ element. createGenericArgument ( ) . withTrailingComma ( index < lastIndex)
1793
+ } )
1740
1794
}
1741
1795
1742
1796
public init ( arrayLiteral elements: ExpressibleAsGenericArgument ... ) {
@@ -1779,7 +1833,10 @@ public struct TuplePatternElementList: ExpressibleByArrayLiteral, SyntaxBuildabl
1779
1833
/// - Parameters:
1780
1834
/// - elements: A list of `ExpressibleAsTuplePatternElement`
1781
1835
public init ( _ elements: [ ExpressibleAsTuplePatternElement ] ) {
1782
- self . elements = elements. map { $0. createTuplePatternElement ( ) }
1836
+ let lastIndex = elements. count - 1
1837
+ self . elements = elements. enumerated ( ) . map ( { index, element in
1838
+ element. createTuplePatternElement ( ) . withTrailingComma ( index < lastIndex)
1839
+ } )
1783
1840
}
1784
1841
1785
1842
public init ( arrayLiteral elements: ExpressibleAsTuplePatternElement ... ) {
0 commit comments