@@ -65,7 +65,13 @@ 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
+ if let last = elements. last {
69
+ self . elements =
70
+ elements. dropLast ( 1 ) . map ( { $0. createTupleExprElement ( isLastElement: false ) } )
71
+ + [ last. createTupleExprElement ( isLastElement: true ) ]
72
+ } else {
73
+ self . elements = [ ]
74
+ }
69
75
}
70
76
71
77
public init ( arrayLiteral elements: ExpressibleAsTupleExprElement ... ) {
@@ -108,7 +114,13 @@ public struct ArrayElementList: ExpressibleByArrayLiteral, SyntaxBuildable, Expr
108
114
/// - Parameters:
109
115
/// - elements: A list of `ExpressibleAsArrayElement`
110
116
public init ( _ elements: [ ExpressibleAsArrayElement ] ) {
111
- self . elements = elements. map { $0. createArrayElement ( ) }
117
+ if let last = elements. last {
118
+ self . elements =
119
+ elements. dropLast ( 1 ) . map ( { $0. createArrayElement ( isLastElement: false ) } )
120
+ + [ last. createArrayElement ( isLastElement: true ) ]
121
+ } else {
122
+ self . elements = [ ]
123
+ }
112
124
}
113
125
114
126
public init ( arrayLiteral elements: ExpressibleAsArrayElement ... ) {
@@ -151,7 +163,13 @@ public struct DictionaryElementList: ExpressibleByArrayLiteral, SyntaxBuildable,
151
163
/// - Parameters:
152
164
/// - elements: A list of `ExpressibleAsDictionaryElement`
153
165
public init ( _ elements: [ ExpressibleAsDictionaryElement ] ) {
154
- self . elements = elements. map { $0. createDictionaryElement ( ) }
166
+ if let last = elements. last {
167
+ self . elements =
168
+ elements. dropLast ( 1 ) . map ( { $0. createDictionaryElement ( isLastElement: false ) } )
169
+ + [ last. createDictionaryElement ( isLastElement: true ) ]
170
+ } else {
171
+ self . elements = [ ]
172
+ }
155
173
}
156
174
157
175
public init ( arrayLiteral elements: ExpressibleAsDictionaryElement ... ) {
@@ -323,7 +341,13 @@ public struct ClosureCaptureItemList: ExpressibleByArrayLiteral, SyntaxBuildable
323
341
/// - Parameters:
324
342
/// - elements: A list of `ExpressibleAsClosureCaptureItem`
325
343
public init ( _ elements: [ ExpressibleAsClosureCaptureItem ] ) {
326
- self . elements = elements. map { $0. createClosureCaptureItem ( ) }
344
+ if let last = elements. last {
345
+ self . elements =
346
+ elements. dropLast ( 1 ) . map ( { $0. createClosureCaptureItem ( isLastElement: false ) } )
347
+ + [ last. createClosureCaptureItem ( isLastElement: true ) ]
348
+ } else {
349
+ self . elements = [ ]
350
+ }
327
351
}
328
352
329
353
public init ( arrayLiteral elements: ExpressibleAsClosureCaptureItem ... ) {
@@ -366,7 +390,13 @@ public struct ClosureParamList: ExpressibleByArrayLiteral, SyntaxBuildable, Expr
366
390
/// - Parameters:
367
391
/// - elements: A list of `ExpressibleAsClosureParam`
368
392
public init ( _ elements: [ ExpressibleAsClosureParam ] ) {
369
- self . elements = elements. map { $0. createClosureParam ( ) }
393
+ if let last = elements. last {
394
+ self . elements =
395
+ elements. dropLast ( 1 ) . map ( { $0. createClosureParam ( isLastElement: false ) } )
396
+ + [ last. createClosureParam ( isLastElement: true ) ]
397
+ } else {
398
+ self . elements = [ ]
399
+ }
370
400
}
371
401
372
402
public init ( arrayLiteral elements: ExpressibleAsClosureParam ... ) {
@@ -495,7 +525,13 @@ public struct FunctionParameterList: ExpressibleByArrayLiteral, SyntaxBuildable,
495
525
/// - Parameters:
496
526
/// - elements: A list of `ExpressibleAsFunctionParameter`
497
527
public init ( _ elements: [ ExpressibleAsFunctionParameter ] ) {
498
- self . elements = elements. map { $0. createFunctionParameter ( ) }
528
+ if let last = elements. last {
529
+ self . elements =
530
+ elements. dropLast ( 1 ) . map ( { $0. createFunctionParameter ( isLastElement: false ) } )
531
+ + [ last. createFunctionParameter ( isLastElement: true ) ]
532
+ } else {
533
+ self . elements = [ ]
534
+ }
499
535
}
500
536
501
537
public init ( arrayLiteral elements: ExpressibleAsFunctionParameter ... ) {
@@ -581,7 +617,13 @@ public struct InheritedTypeList: ExpressibleByArrayLiteral, SyntaxBuildable, Exp
581
617
/// - Parameters:
582
618
/// - elements: A list of `ExpressibleAsInheritedType`
583
619
public init ( _ elements: [ ExpressibleAsInheritedType ] ) {
584
- self . elements = elements. map { $0. createInheritedType ( ) }
620
+ if let last = elements. last {
621
+ self . elements =
622
+ elements. dropLast ( 1 ) . map ( { $0. createInheritedType ( isLastElement: false ) } )
623
+ + [ last. createInheritedType ( isLastElement: true ) ]
624
+ } else {
625
+ self . elements = [ ]
626
+ }
585
627
}
586
628
587
629
public init ( arrayLiteral elements: ExpressibleAsInheritedType ... ) {
@@ -796,7 +838,13 @@ public struct PatternBindingList: ExpressibleByArrayLiteral, SyntaxBuildable, Ex
796
838
/// - Parameters:
797
839
/// - elements: A list of `ExpressibleAsPatternBinding`
798
840
public init ( _ elements: [ ExpressibleAsPatternBinding ] ) {
799
- self . elements = elements. map { $0. createPatternBinding ( ) }
841
+ if let last = elements. last {
842
+ self . elements =
843
+ elements. dropLast ( 1 ) . map ( { $0. createPatternBinding ( isLastElement: false ) } )
844
+ + [ last. createPatternBinding ( isLastElement: true ) ]
845
+ } else {
846
+ self . elements = [ ]
847
+ }
800
848
}
801
849
802
850
public init ( arrayLiteral elements: ExpressibleAsPatternBinding ... ) {
@@ -839,7 +887,13 @@ public struct EnumCaseElementList: ExpressibleByArrayLiteral, SyntaxBuildable, E
839
887
/// - Parameters:
840
888
/// - elements: A list of `ExpressibleAsEnumCaseElement`
841
889
public init ( _ elements: [ ExpressibleAsEnumCaseElement ] ) {
842
- self . elements = elements. map { $0. createEnumCaseElement ( ) }
890
+ if let last = elements. last {
891
+ self . elements =
892
+ elements. dropLast ( 1 ) . map ( { $0. createEnumCaseElement ( isLastElement: false ) } )
893
+ + [ last. createEnumCaseElement ( isLastElement: true ) ]
894
+ } else {
895
+ self . elements = [ ]
896
+ }
843
897
}
844
898
845
899
public init ( arrayLiteral elements: ExpressibleAsEnumCaseElement ... ) {
@@ -1220,7 +1274,13 @@ public struct DifferentiabilityParamList: ExpressibleByArrayLiteral, SyntaxBuild
1220
1274
/// - Parameters:
1221
1275
/// - elements: A list of `ExpressibleAsDifferentiabilityParam`
1222
1276
public init ( _ elements: [ ExpressibleAsDifferentiabilityParam ] ) {
1223
- self . elements = elements. map { $0. createDifferentiabilityParam ( ) }
1277
+ if let last = elements. last {
1278
+ self . elements =
1279
+ elements. dropLast ( 1 ) . map ( { $0. createDifferentiabilityParam ( isLastElement: false ) } )
1280
+ + [ last. createDifferentiabilityParam ( isLastElement: true ) ]
1281
+ } else {
1282
+ self . elements = [ ]
1283
+ }
1224
1284
}
1225
1285
1226
1286
public init ( arrayLiteral elements: ExpressibleAsDifferentiabilityParam ... ) {
@@ -1392,7 +1452,13 @@ public struct CaseItemList: ExpressibleByArrayLiteral, SyntaxBuildable, Expressi
1392
1452
/// - Parameters:
1393
1453
/// - elements: A list of `ExpressibleAsCaseItem`
1394
1454
public init ( _ elements: [ ExpressibleAsCaseItem ] ) {
1395
- self . elements = elements. map { $0. createCaseItem ( ) }
1455
+ if let last = elements. last {
1456
+ self . elements =
1457
+ elements. dropLast ( 1 ) . map ( { $0. createCaseItem ( isLastElement: false ) } )
1458
+ + [ last. createCaseItem ( isLastElement: true ) ]
1459
+ } else {
1460
+ self . elements = [ ]
1461
+ }
1396
1462
}
1397
1463
1398
1464
public init ( arrayLiteral elements: ExpressibleAsCaseItem ... ) {
@@ -1435,7 +1501,13 @@ public struct CatchItemList: ExpressibleByArrayLiteral, SyntaxBuildable, Express
1435
1501
/// - Parameters:
1436
1502
/// - elements: A list of `ExpressibleAsCatchItem`
1437
1503
public init ( _ elements: [ ExpressibleAsCatchItem ] ) {
1438
- self . elements = elements. map { $0. createCatchItem ( ) }
1504
+ if let last = elements. last {
1505
+ self . elements =
1506
+ elements. dropLast ( 1 ) . map ( { $0. createCatchItem ( isLastElement: false ) } )
1507
+ + [ last. createCatchItem ( isLastElement: true ) ]
1508
+ } else {
1509
+ self . elements = [ ]
1510
+ }
1439
1511
}
1440
1512
1441
1513
public init ( arrayLiteral elements: ExpressibleAsCatchItem ... ) {
@@ -1478,7 +1550,13 @@ public struct ConditionElementList: ExpressibleByArrayLiteral, SyntaxBuildable,
1478
1550
/// - Parameters:
1479
1551
/// - elements: A list of `ExpressibleAsConditionElement`
1480
1552
public init ( _ elements: [ ExpressibleAsConditionElement ] ) {
1481
- self . elements = elements. map { $0. createConditionElement ( ) }
1553
+ if let last = elements. last {
1554
+ self . elements =
1555
+ elements. dropLast ( 1 ) . map ( { $0. createConditionElement ( isLastElement: false ) } )
1556
+ + [ last. createConditionElement ( isLastElement: true ) ]
1557
+ } else {
1558
+ self . elements = [ ]
1559
+ }
1482
1560
}
1483
1561
1484
1562
public init ( arrayLiteral elements: ExpressibleAsConditionElement ... ) {
@@ -1521,7 +1599,13 @@ public struct GenericRequirementList: ExpressibleByArrayLiteral, SyntaxBuildable
1521
1599
/// - Parameters:
1522
1600
/// - elements: A list of `ExpressibleAsGenericRequirement`
1523
1601
public init ( _ elements: [ ExpressibleAsGenericRequirement ] ) {
1524
- self . elements = elements. map { $0. createGenericRequirement ( ) }
1602
+ if let last = elements. last {
1603
+ self . elements =
1604
+ elements. dropLast ( 1 ) . map ( { $0. createGenericRequirement ( isLastElement: false ) } )
1605
+ + [ last. createGenericRequirement ( isLastElement: true ) ]
1606
+ } else {
1607
+ self . elements = [ ]
1608
+ }
1525
1609
}
1526
1610
1527
1611
public init ( arrayLiteral elements: ExpressibleAsGenericRequirement ... ) {
@@ -1564,7 +1648,13 @@ public struct GenericParameterList: ExpressibleByArrayLiteral, SyntaxBuildable,
1564
1648
/// - Parameters:
1565
1649
/// - elements: A list of `ExpressibleAsGenericParameter`
1566
1650
public init ( _ elements: [ ExpressibleAsGenericParameter ] ) {
1567
- self . elements = elements. map { $0. createGenericParameter ( ) }
1651
+ if let last = elements. last {
1652
+ self . elements =
1653
+ elements. dropLast ( 1 ) . map ( { $0. createGenericParameter ( isLastElement: false ) } )
1654
+ + [ last. createGenericParameter ( isLastElement: true ) ]
1655
+ } else {
1656
+ self . elements = [ ]
1657
+ }
1568
1658
}
1569
1659
1570
1660
public init ( arrayLiteral elements: ExpressibleAsGenericParameter ... ) {
@@ -1607,7 +1697,13 @@ public struct PrimaryAssociatedTypeList: ExpressibleByArrayLiteral, SyntaxBuilda
1607
1697
/// - Parameters:
1608
1698
/// - elements: A list of `ExpressibleAsPrimaryAssociatedType`
1609
1699
public init ( _ elements: [ ExpressibleAsPrimaryAssociatedType ] ) {
1610
- self . elements = elements. map { $0. createPrimaryAssociatedType ( ) }
1700
+ if let last = elements. last {
1701
+ self . elements =
1702
+ elements. dropLast ( 1 ) . map ( { $0. createPrimaryAssociatedType ( isLastElement: false ) } )
1703
+ + [ last. createPrimaryAssociatedType ( isLastElement: true ) ]
1704
+ } else {
1705
+ self . elements = [ ]
1706
+ }
1611
1707
}
1612
1708
1613
1709
public init ( arrayLiteral elements: ExpressibleAsPrimaryAssociatedType ... ) {
@@ -1693,7 +1789,13 @@ public struct TupleTypeElementList: ExpressibleByArrayLiteral, SyntaxBuildable,
1693
1789
/// - Parameters:
1694
1790
/// - elements: A list of `ExpressibleAsTupleTypeElement`
1695
1791
public init ( _ elements: [ ExpressibleAsTupleTypeElement ] ) {
1696
- self . elements = elements. map { $0. createTupleTypeElement ( ) }
1792
+ if let last = elements. last {
1793
+ self . elements =
1794
+ elements. dropLast ( 1 ) . map ( { $0. createTupleTypeElement ( isLastElement: false ) } )
1795
+ + [ last. createTupleTypeElement ( isLastElement: true ) ]
1796
+ } else {
1797
+ self . elements = [ ]
1798
+ }
1697
1799
}
1698
1800
1699
1801
public init ( arrayLiteral elements: ExpressibleAsTupleTypeElement ... ) {
@@ -1736,7 +1838,13 @@ public struct GenericArgumentList: ExpressibleByArrayLiteral, SyntaxBuildable, E
1736
1838
/// - Parameters:
1737
1839
/// - elements: A list of `ExpressibleAsGenericArgument`
1738
1840
public init ( _ elements: [ ExpressibleAsGenericArgument ] ) {
1739
- self . elements = elements. map { $0. createGenericArgument ( ) }
1841
+ if let last = elements. last {
1842
+ self . elements =
1843
+ elements. dropLast ( 1 ) . map ( { $0. createGenericArgument ( isLastElement: false ) } )
1844
+ + [ last. createGenericArgument ( isLastElement: true ) ]
1845
+ } else {
1846
+ self . elements = [ ]
1847
+ }
1740
1848
}
1741
1849
1742
1850
public init ( arrayLiteral elements: ExpressibleAsGenericArgument ... ) {
@@ -1779,7 +1887,13 @@ public struct TuplePatternElementList: ExpressibleByArrayLiteral, SyntaxBuildabl
1779
1887
/// - Parameters:
1780
1888
/// - elements: A list of `ExpressibleAsTuplePatternElement`
1781
1889
public init ( _ elements: [ ExpressibleAsTuplePatternElement ] ) {
1782
- self . elements = elements. map { $0. createTuplePatternElement ( ) }
1890
+ if let last = elements. last {
1891
+ self . elements =
1892
+ elements. dropLast ( 1 ) . map ( { $0. createTuplePatternElement ( isLastElement: false ) } )
1893
+ + [ last. createTuplePatternElement ( isLastElement: true ) ]
1894
+ } else {
1895
+ self . elements = [ ]
1896
+ }
1783
1897
}
1784
1898
1785
1899
public init ( arrayLiteral elements: ExpressibleAsTuplePatternElement ... ) {
0 commit comments