Skip to content

Commit 7925070

Browse files
Merge pull request #3698 from PatrickPijnappel/spacing
[stdlib] Standardize function signature spacing
2 parents 8b221e7 + 2728bd0 commit 7925070

23 files changed

+71
-69
lines changed

stdlib/public/core/Bool.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ extension Bool : Equatable, Hashable {
141141
}
142142

143143
@_transparent
144-
public static func ==(lhs: Bool, rhs: Bool) -> Bool {
144+
public static func == (lhs: Bool, rhs: Bool) -> Bool {
145145
return Bool(Builtin.cmp_eq_Int1(lhs._value, rhs._value))
146146
}
147147
}
@@ -167,7 +167,7 @@ extension Bool {
167167
///
168168
/// - Parameter a: The Boolean value to negate.
169169
@_transparent
170-
public static prefix func !(a: Bool) -> Bool {
170+
public static prefix func ! (a: Bool) -> Bool {
171171
return Bool(Builtin.xor_Int1(a._value, true._value))
172172
}
173173
}
@@ -206,7 +206,7 @@ extension Bool {
206206
/// - lhs: The left-hand side of the operation.
207207
/// - rhs: The right-hand side of the operation.
208208
@inline(__always)
209-
public static func &&(lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows
209+
public static func && (lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows
210210
-> Bool{
211211
return lhs ? try rhs() : false
212212
}
@@ -245,7 +245,7 @@ extension Bool {
245245
/// - lhs: The left-hand side of the operation.
246246
/// - rhs: The right-hand side of the operation.
247247
@inline(__always)
248-
public static func ||(lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows
248+
public static func || (lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows
249249
-> Bool {
250250
return lhs ? true : try rhs()
251251
}

stdlib/public/core/BridgeObjectiveC.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,10 @@ public func _forceBridgeFromObjectiveC<T>(_ x: AnyObject, _: T.Type) -> T {
246246
/// Convert `x` from its Objective-C representation to its Swift
247247
/// representation.
248248
@_silgen_name("_forceBridgeFromObjectiveC_bridgeable")
249-
public func _forceBridgeFromObjectiveC_bridgeable<T:_ObjectiveCBridgeable>
250-
(_ x: T._ObjectiveCType, _: T.Type) -> T {
249+
public func _forceBridgeFromObjectiveC_bridgeable<T:_ObjectiveCBridgeable> (
250+
_ x: T._ObjectiveCType,
251+
_: T.Type
252+
) -> T {
251253
var result: T?
252254
T._forceBridgeFromObjectiveC(x, result: &result)
253255
return result!
@@ -483,7 +485,7 @@ extension AutoreleasingUnsafeMutablePointer : CustomDebugStringConvertible {
483485
}
484486

485487
@_transparent
486-
public func == <Pointee> (
488+
public func == <Pointee>(
487489
lhs: AutoreleasingUnsafeMutablePointer<Pointee>,
488490
rhs: AutoreleasingUnsafeMutablePointer<Pointee>
489491
) -> Bool {

stdlib/public/core/Builtin.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,22 @@ internal func _reinterpretCastToAnyObject<T>(_ x: T) -> AnyObject {
129129
}
130130

131131
@_transparent
132-
func ==(lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
132+
func == (lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
133133
return unsafeBitCast(lhs, to: Int.self) == unsafeBitCast(rhs, to: Int.self)
134134
}
135135

136136
@_transparent
137-
func !=(lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
137+
func != (lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
138138
return !(lhs == rhs)
139139
}
140140

141141
@_transparent
142-
func ==(lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
142+
func == (lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
143143
return unsafeBitCast(lhs, to: Int.self) == unsafeBitCast(rhs, to: Int.self)
144144
}
145145

146146
@_transparent
147-
func !=(lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
147+
func != (lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
148148
return !(lhs == rhs)
149149
}
150150

stdlib/public/core/CTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ extension UInt {
162162
}
163163

164164
extension OpaquePointer : Equatable {
165-
public static func ==(lhs: OpaquePointer, rhs: OpaquePointer) -> Bool {
165+
public static func == (lhs: OpaquePointer, rhs: OpaquePointer) -> Bool {
166166
return Bool(Builtin.cmp_eq_RawPointer(lhs._rawValue, rhs._rawValue))
167167
}
168168
}

stdlib/public/core/Character.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ internal var _minASCIICharReprBuiltin: Builtin.Int63 {
392392
}
393393

394394
extension Character : Equatable {
395-
public static func ==(lhs: Character, rhs: Character) -> Bool {
395+
public static func == (lhs: Character, rhs: Character) -> Bool {
396396
switch (lhs._representation, rhs._representation) {
397397
case let (.small(lbits), .small(rbits)) where
398398
Bool(Builtin.cmp_uge_Int63(lbits, _minASCIICharReprBuiltin))
@@ -407,7 +407,7 @@ extension Character : Equatable {
407407
}
408408

409409
extension Character : Comparable {
410-
public static func <(lhs: Character, rhs: Character) -> Bool {
410+
public static func < (lhs: Character, rhs: Character) -> Bool {
411411
switch (lhs._representation, rhs._representation) {
412412
case let (.small(lbits), .small(rbits)) where
413413
// Note: This is consistent with Foundation but unicode incorrect.

stdlib/public/core/ClosedRange.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public struct ClosedRange<
395395
/// - minimum: The lower bound for the range.
396396
/// - maximum: The upper bound for the range.
397397
@_transparent
398-
public func ... <Bound : Comparable> (minimum: Bound, maximum: Bound)
398+
public func ... <Bound : Comparable>(minimum: Bound, maximum: Bound)
399399
-> ClosedRange<Bound> {
400400
_precondition(
401401
minimum <= maximum, "Can't form Range with upperBound < lowerBound")
@@ -414,7 +414,7 @@ public func ... <Bound : Comparable> (minimum: Bound, maximum: Bound)
414414
/// - minimum: The lower bound for the range.
415415
/// - maximum: The upper bound for the range.
416416
@_transparent
417-
public func ... <Bound> (
417+
public func ... <Bound>(
418418
minimum: Bound, maximum: Bound
419419
) -> CountableClosedRange<Bound>
420420
where

stdlib/public/core/Comparable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
/// `Comparable` and implement the `<` operator function.
8484
///
8585
/// extension Date: Comparable {
86-
/// static func <(lhs: Date, rhs: Date) -> Bool {
86+
/// static func < (lhs: Date, rhs: Date) -> Bool {
8787
/// if lhs.year != rhs.year {
8888
/// return lhs.year < rhs.year
8989
/// } else if lhs.month != rhs.month {
@@ -102,7 +102,7 @@
102102
/// Next, implement the `==` operator function, the requirement inherited from
103103
/// the `Equatable` protocol.
104104
///
105-
/// func ==(lhs: Date, rhs: Date) -> Bool {
105+
/// func == (lhs: Date, rhs: Date) -> Bool {
106106
/// return lhs.year == rhs.year && lhs.month == rhs.month
107107
/// && lhs.day == rhs.day
108108
/// }

stdlib/public/core/Equatable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
/// `Equatable`.
7777
///
7878
/// extension StreetAddress: Equatable {
79-
/// static func ==(lhs: StreetAddress, rhs: StreetAddress) -> Bool {
79+
/// static func == (lhs: StreetAddress, rhs: StreetAddress) -> Bool {
8080
/// return
8181
/// lhs.number == rhs.number &&
8282
/// lhs.street == rhs.street &&
@@ -132,7 +132,7 @@
132132
/// self.value = value
133133
/// }
134134
///
135-
/// static func ==(lhs: IntegerRef, rhs: IntegerRef) -> Bool {
135+
/// static func == (lhs: IntegerRef, rhs: IntegerRef) -> Bool {
136136
/// return lhs.value == rhs.value
137137
/// }
138138
/// }

stdlib/public/core/FixedPoint.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ public func ${op}(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
570570
///
571571
/// - SeeAlso: `BitwiseOperations`
572572
@_transparent
573-
public prefix func ~(rhs: ${Self}) -> ${Self} {
573+
public prefix func ~ (rhs: ${Self}) -> ${Self} {
574574
let mask = ${Self}.subtractWithOverflow(0, 1).0
575575
return ${Self}(Builtin.xor_${BuiltinName}(rhs._value, mask._value))
576576
}

stdlib/public/core/FloatingPoint.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,12 @@ public enum FloatingPointRoundingRule {
541541
}
542542

543543
@_transparent
544-
public prefix func +<T : FloatingPoint>(x: T) -> T {
544+
public prefix func + <T : FloatingPoint>(x: T) -> T {
545545
return x
546546
}
547547

548548
@_transparent
549-
public prefix func -<T : FloatingPoint>(x: T) -> T {
549+
public prefix func - <T : FloatingPoint>(x: T) -> T {
550550
return x.negated()
551551
}
552552

@@ -573,7 +573,7 @@ public func ${op[0]}=<T : FloatingPoint>(lhs: inout T, rhs: T) {
573573
%end
574574

575575
@_transparent
576-
public func ==<T : FloatingPoint>(lhs: T, rhs: T) -> Bool {
576+
public func == <T : FloatingPoint>(lhs: T, rhs: T) -> Bool {
577577
return lhs.isEqual(to: rhs)
578578
}
579579

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -756,12 +756,12 @@ extension ${Self} : Arithmetic {
756756
}
757757

758758
@_transparent
759-
public prefix func +(x: ${Self}) -> ${Self} {
759+
public prefix func + (x: ${Self}) -> ${Self} {
760760
return x
761761
}
762762

763763
@_transparent
764-
public prefix func -(x: ${Self}) -> ${Self} {
764+
public prefix func - (x: ${Self}) -> ${Self} {
765765
return ${Self}(_bits: Builtin.fneg_FPIEEE${bits}(x._value))
766766
}
767767

@@ -838,42 +838,42 @@ extension ${Self} {
838838
// definitions in the standard lib, or both.
839839

840840
@_transparent
841-
public func +(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
841+
public func + (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
842842
return lhs.adding(rhs)
843843
}
844844

845845
@_transparent
846-
public func -(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
846+
public func - (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
847847
return lhs.subtracting(rhs)
848848
}
849849

850850
@_transparent
851-
public func *(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
851+
public func * (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
852852
return lhs.multiplied(by: rhs)
853853
}
854854

855855
@_transparent
856-
public func /(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
856+
public func / (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
857857
return lhs.divided(by: rhs)
858858
}
859859

860860
@_transparent
861-
public func +=(lhs: inout ${Self}, rhs: ${Self}) {
861+
public func += (lhs: inout ${Self}, rhs: ${Self}) {
862862
lhs.add(rhs)
863863
}
864864

865865
@_transparent
866-
public func -=(lhs: inout ${Self}, rhs: ${Self}) {
866+
public func -= (lhs: inout ${Self}, rhs: ${Self}) {
867867
lhs.subtract(rhs)
868868
}
869869

870870
@_transparent
871-
public func *=(lhs: inout ${Self}, rhs: ${Self}) {
871+
public func *= (lhs: inout ${Self}, rhs: ${Self}) {
872872
lhs.multiply(by: rhs)
873873
}
874874

875875
@_transparent
876-
public func /=(lhs: inout ${Self}, rhs: ${Self}) {
876+
public func /= (lhs: inout ${Self}, rhs: ${Self}) {
877877
lhs.divide(by: rhs)
878878
}
879879

@@ -908,38 +908,38 @@ extension ${Self} : Strideable {
908908

909909
@_transparent
910910
@available(*, unavailable, message: "Use truncatingRemainder instead")
911-
public func %(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
911+
public func % (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
912912
fatalError("% is not available.")
913913
}
914914

915915
@_transparent
916916
@available(*, unavailable, message: "Use formTruncatingRemainder instead")
917-
public func %=(lhs: inout ${Self}, rhs: ${Self}) {
917+
public func %= (lhs: inout ${Self}, rhs: ${Self}) {
918918
fatalError("%= is not available.")
919919
}
920920

921921
@_transparent
922922
@available(*, unavailable, message: "use += 1")
923923
@discardableResult
924-
public prefix func ++(rhs: inout ${Self}) -> ${Self} {
924+
public prefix func ++ (rhs: inout ${Self}) -> ${Self} {
925925
fatalError("++ is not available")
926926
}
927927
@_transparent
928928
@available(*, unavailable, message: "use -= 1")
929929
@discardableResult
930-
public prefix func --(rhs: inout ${Self}) -> ${Self} {
930+
public prefix func -- (rhs: inout ${Self}) -> ${Self} {
931931
fatalError("-- is not available")
932932
}
933933
@_transparent
934934
@available(*, unavailable, message: "use += 1")
935935
@discardableResult
936-
public postfix func ++(lhs: inout ${Self}) -> ${Self} {
936+
public postfix func ++ (lhs: inout ${Self}) -> ${Self} {
937937
fatalError("++ is not available")
938938
}
939939
@_transparent
940940
@available(*, unavailable, message: "use -= 1")
941941
@discardableResult
942-
public postfix func --(lhs: inout ${Self}) -> ${Self} {
942+
public postfix func -- (lhs: inout ${Self}) -> ${Self} {
943943
fatalError("-- is not available")
944944
}
945945

stdlib/public/core/Hashable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
/// return x.hashValue ^ y.hashValue
6060
/// }
6161
///
62-
/// static func ==(lhs: GridPoint, rhs: GridPoint) -> Bool {
62+
/// static func == (lhs: GridPoint, rhs: GridPoint) -> Bool {
6363
/// return lhs.x == rhs.x && lhs.y == rhs.y
6464
/// }
6565
/// }

stdlib/public/core/HashedCollections.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4505,7 +4505,7 @@ internal struct _Cocoa${Self}Index : Comparable {
45054505
}
45064506

45074507
extension _Cocoa${Self}Index {
4508-
internal static func ==(
4508+
internal static func == (
45094509
lhs: _Cocoa${Self}Index,
45104510
rhs: _Cocoa${Self}Index
45114511
) -> Bool {
@@ -4517,7 +4517,7 @@ extension _Cocoa${Self}Index {
45174517
return lhs.currentKeyIndex == rhs.currentKeyIndex
45184518
}
45194519

4520-
internal static func <(
4520+
internal static func < (
45214521
lhs: _Cocoa${Self}Index,
45224522
rhs: _Cocoa${Self}Index
45234523
) -> Bool {

stdlib/public/core/HeapBuffer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ struct _HeapBuffer<Value, Element> : Equatable {
220220

221221
// HeapBuffers are equal when they reference the same buffer
222222
public // @testable
223-
func == <Value, Element> (
223+
func == <Value, Element>(
224224
lhs: _HeapBuffer<Value, Element>,
225225
rhs: _HeapBuffer<Value, Element>) -> Bool {
226226
return lhs._nativeObject == rhs._nativeObject

stdlib/public/core/Index.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ public protocol _Incrementable : Equatable {}
1717

1818
@available(*, unavailable, message: "Use \'-= 1\' or call collection.prior(Index)")
1919
@discardableResult
20-
public prefix func -- <T : _Incrementable> (i: inout T) -> T {
20+
public prefix func -- <T : _Incrementable>(i: inout T) -> T {
2121
Builtin.unreachable()
2222
}
2323

2424
@available(*, unavailable, message: "Use \'-= 1\' or call collection.prior(Index)")
2525
@discardableResult
26-
public postfix func -- <T : _Incrementable> (i: inout T) -> T {
26+
public postfix func -- <T : _Incrementable>(i: inout T) -> T {
2727
Builtin.unreachable()
2828
}
2929

3030
@available(*, unavailable, message: "Use \'+= 1\' or call 'collection.index(after: Index)")
3131
@discardableResult
32-
public prefix func ++ <T : _Incrementable> (i: inout T) -> T {
32+
public prefix func ++ <T : _Incrementable>(i: inout T) -> T {
3333
Builtin.unreachable()
3434
}
3535

3636
@available(*, unavailable, message: "Use \'+= 1\' or call 'collection.index(after: Index)")
3737
@discardableResult
38-
public postfix func ++ <T : _Incrementable> (i: inout T) -> T {
38+
public postfix func ++ <T : _Incrementable>(i: inout T) -> T {
3939
Builtin.unreachable()
4040
}
4141

stdlib/public/core/Integers.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public func ${x.operator}= <T: ${Protocol}>(lhs: inout T, rhs: T) {
175175
% end
176176

177177
@_transparent
178-
public prefix func -<T: SignedArithmetic>(x: T) -> T {
178+
public prefix func - <T: SignedArithmetic>(x: T) -> T {
179179
return x.negated()
180180
}
181181

0 commit comments

Comments
 (0)