@@ -47,8 +47,6 @@ public extension Position2n where Scalar: FloatingPoint {
4747 }
4848}
4949extension Position2n : AdditiveArithmetic where Scalar: AdditiveArithmetic { }
50- extension Position2n : ExpressibleByIntegerLiteral where Scalar: FixedWidthInteger & _ExpressibleByBuiltinIntegerLiteral & ExpressibleByIntegerLiteral { }
51- extension Position2n : ExpressibleByFloatLiteral where Scalar: FloatingPoint & _ExpressibleByBuiltinFloatLiteral & ExpressibleByFloatLiteral { }
5250extension Position2n : Equatable where Scalar: Equatable { }
5351extension Position2n : Hashable where Scalar: Hashable { }
5452extension Position2n : Comparable where Scalar: Comparable { }
@@ -78,8 +76,6 @@ public extension Direction2n where Scalar: FloatingPoint {
7876 }
7977}
8078extension Direction2n : AdditiveArithmetic where Scalar: AdditiveArithmetic { }
81- extension Direction2n : ExpressibleByIntegerLiteral where Scalar: FixedWidthInteger & _ExpressibleByBuiltinIntegerLiteral & ExpressibleByIntegerLiteral { }
82- extension Direction2n : ExpressibleByFloatLiteral where Scalar: FloatingPoint & _ExpressibleByBuiltinFloatLiteral & ExpressibleByFloatLiteral { }
8379extension Direction2n : Equatable where Scalar: Equatable { }
8480extension Direction2n : Hashable where Scalar: Hashable { }
8581extension Direction2n : Comparable where Scalar: Comparable { }
@@ -103,8 +99,6 @@ public struct Size2n<Scalar: Vector2n.ScalarType>: Vector2n {
10399 public static var one : Self { . init( x: 1 , y: 1 ) }
104100}
105101extension Size2n : AdditiveArithmetic where Scalar: AdditiveArithmetic { }
106- extension Size2n : ExpressibleByIntegerLiteral where Scalar: FixedWidthInteger & _ExpressibleByBuiltinIntegerLiteral & ExpressibleByIntegerLiteral { }
107- extension Size2n : ExpressibleByFloatLiteral where Scalar: FloatingPoint & _ExpressibleByBuiltinFloatLiteral & ExpressibleByFloatLiteral { }
108102extension Size2n : Equatable where Scalar: Equatable { }
109103extension Size2n : Hashable where Scalar: Hashable { }
110104extension Size2n : Comparable where Scalar: Comparable { }
@@ -242,20 +236,6 @@ extension Vector2n where Scalar: BinaryFloatingPoint {
242236 }
243237}
244238
245- public extension Vector2n where Scalar: FixedWidthInteger & _ExpressibleByBuiltinIntegerLiteral & ExpressibleByIntegerLiteral {
246- typealias IntegerLiteralType = Scalar
247- init ( integerLiteral value: IntegerLiteralType ) {
248- self . init ( x: value, y: value)
249- }
250- }
251-
252- public extension Vector2n where Scalar: FloatingPoint & _ExpressibleByBuiltinFloatLiteral & ExpressibleByFloatLiteral {
253- typealias FloatLiteralType = Scalar
254- init ( floatLiteral value: FloatLiteralType ) {
255- self . init ( x: value, y: value)
256- }
257- }
258-
259239public extension Vector2n where Scalar: AdditiveArithmetic {
260240 @inlinable
261241 static func + ( lhs: Self , rhs: some Vector2n < Scalar > ) -> Self {
@@ -277,9 +257,8 @@ public extension Vector2n where Scalar: AdditiveArithmetic {
277257 return Self ( x: lhs. x - rhs, y: lhs. y - rhs)
278258 }
279259
280- @_disfavoredOverload // <- Tell the compiler to prefer using integer literals to avoid ambiguilty
281260 @inlinable
282- static var zero : Self { Self ( x: Scalar . zero, y: Scalar . zero) }
261+ static var zero : Self { Self ( x: . zero, y: . zero) }
283262}
284263
285264public extension Vector2n where Scalar: Numeric {
@@ -356,6 +335,13 @@ public extension Vector2n where Scalar: FloatingPoint {
356335 )
357336 }
358337
338+ @inlinable
339+ var isFinite : Bool {
340+ nonmutating get {
341+ return x. isFinite && y. isFinite
342+ }
343+ }
344+
359345 @inlinable
360346 static var nan : Self { Self ( x: . nan, y: . nan) }
361347
@@ -479,7 +465,7 @@ public extension Vector2n {
479465 }
480466}
481467
482- public extension Vector2n where Scalar: FloatingPoint {
468+ public extension Vector2n where Scalar: FloatingPoint , Self : Equatable {
483469 @inlinable
484470 var magnitude : Scalar {
485471 nonmutating get {
@@ -494,7 +480,7 @@ public extension Vector2n where Scalar: FloatingPoint {
494480
495481 @inlinable
496482 mutating func normalize( ) {
497- guard self != 0 else { return }
483+ guard self != Self . zero else { return }
498484 let magnitude = self . magnitude
499485 let factor = 1 / magnitude
500486 self *= factor
@@ -510,8 +496,6 @@ public extension Vector2n where Scalar: FloatingPoint {
510496 }
511497}
512498
513-
514-
515499extension Vector2n where Scalar: BinaryCodable {
516500 public func encode( into data: inout ContiguousArray < UInt8 > , version: BinaryCodableVersion ) throws {
517501 try self . x. encode ( into: & data, version: version)
0 commit comments