@@ -15,8 +15,8 @@ public protocol Vector2n<Scalar> {
1515 init ( x: Scalar , y: Scalar )
1616}
1717
18- public typealias Position2i = Position2n < Int32 >
19- public typealias Position2f = Position2n < Float32 >
18+ public typealias Position2i = Position2n < Int >
19+ public typealias Position2f = Position2n < Float >
2020public struct Position2n < Scalar: Vector2n . ScalarType > : Vector2n {
2121 public typealias Vector2Counterpart = Position2
2222 public var x : Scalar
@@ -35,8 +35,8 @@ extension Position2n: Sendable where Scalar: Sendable { }
3535extension Position2n : Codable where Scalar: Codable { }
3636extension Position2n : BinaryCodable where Scalar: BinaryCodable { }
3737
38- public typealias Size2i = Size2n < Int32 >
39- public typealias Size2f = Size2n < Float32 >
38+ public typealias Size2i = Size2n < Int >
39+ public typealias Size2f = Size2n < Float >
4040public struct Size2n < Scalar: Vector2n . ScalarType > : Vector2n {
4141 public typealias Vector2Counterpart = Size2
4242 public var x : Scalar
@@ -65,58 +65,6 @@ public extension Size2n {
6565 }
6666}
6767
68- public extension Vector2n where Scalar: BinaryInteger {
69- @inlinable
70- @_disfavoredOverload
71- static func castInit< T1: BinaryInteger , T2: BinaryInteger > ( width: T1 , height: T2 ) -> Self {
72- return . init( x: Scalar ( width) , y: Scalar ( height) )
73- }
74-
75- @inlinable
76- @_disfavoredOverload
77- static func castInit< T1: BinaryFloatingPoint , T2: BinaryFloatingPoint > ( width: T1 , height: T2 ) -> Self {
78- return . init( x: Scalar ( width) , y: Scalar ( height) )
79- }
80-
81- @inlinable
82- @_disfavoredOverload
83- static func castInit< T1: BinaryInteger , T2: BinaryFloatingPoint > ( width: T1 , height: T2 ) -> Self {
84- return . init( x: Scalar ( width) , y: Scalar ( height) )
85- }
86-
87- @inlinable
88- @_disfavoredOverload
89- static func castInit< T1: BinaryFloatingPoint , T2: BinaryInteger > ( width: T1 , height: T2 ) -> Self {
90- return . init( x: Scalar ( width) , y: Scalar ( height) )
91- }
92- }
93-
94- public extension Vector2n where Scalar: BinaryFloatingPoint {
95- @inlinable
96- @_disfavoredOverload
97- static func castInit< T1: BinaryInteger , T2: BinaryInteger > ( width: T1 , height: T2 ) -> Self {
98- return . init( x: Scalar ( width) , y: Scalar ( height) )
99- }
100-
101- @inlinable
102- @_disfavoredOverload
103- static func castInit< T1: BinaryFloatingPoint , T2: BinaryFloatingPoint > ( width: T1 , height: T2 ) -> Self {
104- return . init( x: Scalar ( width) , y: Scalar ( height) )
105- }
106-
107- @inlinable
108- @_disfavoredOverload
109- static func castInit< T1: BinaryInteger , T2: BinaryFloatingPoint > ( width: T1 , height: T2 ) -> Self {
110- return . init( x: Scalar ( width) , y: Scalar ( height) )
111- }
112-
113- @inlinable
114- @_disfavoredOverload
115- static func castInit< T1: BinaryFloatingPoint , T2: BinaryInteger > ( width: T1 , height: T2 ) -> Self {
116- return . init( x: Scalar ( width) , y: Scalar ( height) )
117- }
118- }
119-
12068extension Vector2n where Scalar: BinaryInteger {
12169 @inlinable
12270 public init ( _ vector2n: some Vector2n < Scalar > ) {
@@ -206,25 +154,6 @@ public extension Vector2n where Scalar: Numeric {
206154 }
207155}
208156
209- extension Vector2n where Scalar: Comparable {
210- public static func < ( lhs: Self , rhs: some Vector2n < Scalar > ) -> Bool {
211- return lhs. x < rhs. x && lhs. y < rhs. y
212- }
213- }
214-
215- extension Vector2n where Scalar: Equatable {
216- public static func == ( lhs: Self , rhs: some Vector2n < Scalar > ) -> Bool {
217- return lhs. x == rhs. x && lhs. y == rhs. y
218- }
219- }
220-
221- extension Vector2n where Scalar: Hashable {
222- public func hash( into hasher: inout Hasher ) {
223- hasher. combine ( x)
224- hasher. combine ( y)
225- }
226- }
227-
228157public extension Vector2n where Scalar: FloatingPoint {
229158 @inlinable
230159 static func / ( lhs: Self , rhs: some Vector2n < Scalar > ) -> Self {
@@ -249,6 +178,27 @@ public extension Vector2n where Scalar: FixedWidthInteger {
249178 }
250179}
251180
181+ public extension Vector2n where Scalar: Comparable {
182+ @inlinable
183+ static func < ( lhs: Self , rhs: some Vector2n < Scalar > ) -> Bool {
184+ return lhs. x < rhs. x && lhs. y < rhs. y
185+ }
186+ }
187+
188+ extension Vector2n where Scalar: Equatable {
189+ @inlinable
190+ public static func == ( lhs: Self , rhs: some Vector2n < Scalar > ) -> Bool {
191+ return lhs. x == rhs. x && lhs. y == rhs. y
192+ }
193+ }
194+
195+ extension Vector2n where Scalar: Hashable {
196+ public func hash( into hasher: inout Hasher ) {
197+ hasher. combine ( x)
198+ hasher. combine ( y)
199+ }
200+ }
201+
252202extension Vector2n where Scalar: BinaryCodable {
253203 public func encode( into data: inout ContiguousArray < UInt8 > , version: BinaryCodableVersion ) throws {
254204 try self . x. encode ( into: & data, version: version)
0 commit comments