Skip to content

Commit 367a3b3

Browse files
authored
Merge pull request #23 from RougeWare/develop
Sync Develop into Master
2 parents f12fd67 + 9086bf6 commit 367a3b3

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

Sources/RectangleTools/Synthesized Conveniences/DualTwoDimensional Extensions.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ public extension DualTwoDimensional
2929
}
3030

3131

32+
/// Creates a new dual 2D object by converting the values of the given one
33+
///
34+
/// - Parameter other: Another dual 2D object to convert
35+
init<Other>(_ other: Other)
36+
where Other: DualTwoDimensional,
37+
Other.FirstDimensionPair.Length: BinaryFloatingPoint,
38+
Other.SecondDimensionPair.Length: BinaryFloatingPoint
39+
{
40+
self.init(firstDimensionPair: .init(other.firstDimensionPair),
41+
secondDimensionPair: .init(other.secondDimensionPair))
42+
}
43+
44+
3245
/// Attempts to create a new dual 2D object by converting the values of the given one. If that can't be done (e.g.
3346
/// the other's bit width is larger than this one), `nil` is returned.
3447
///
@@ -81,6 +94,19 @@ public extension DualTwoDimensional
8194
SecondDimensionPair.Length: BinaryFloatingPoint
8295
{
8396

97+
/// Creates a new dual 2D object by converting the values of the given one
98+
///
99+
/// - Parameter other: Another dual 2D object to convert
100+
init<Other>(_ other: Other)
101+
where Other: DualTwoDimensional,
102+
Other.FirstDimensionPair.Length: BinaryInteger,
103+
Other.SecondDimensionPair.Length: BinaryInteger
104+
{
105+
self.init(firstDimensionPair: .init(other.firstDimensionPair),
106+
secondDimensionPair: .init(other.secondDimensionPair))
107+
}
108+
109+
84110
/// Creates a new dual 2D object by converting the values of the given one
85111
///
86112
/// - Parameter other: Another dual 2D object to convert

Sources/RectangleTools/Synthesized Conveniences/TwoDimensional Extensions.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ import Foundation
1212

1313
public extension TwoDimensional where Length: BinaryFloatingPoint {
1414

15+
/// Creates a new 2D object by converting the values of the given one
16+
///
17+
/// - Parameter other: Another 2D object to convert
18+
init<Other>(_ other: Other)
19+
where Other: TwoDimensional,
20+
Other.Length: BinaryInteger
21+
{
22+
self.init(measurementX: Length.init(other.measurementX), measurementY: Length.init(other.measurementY))
23+
}
24+
25+
1526
/// Creates a new 2D object by converting the values of the given one
1627
///
1728
/// - Parameter other: Another 2D object to convert
@@ -80,6 +91,17 @@ public extension TwoDimensional where Length: BinaryInteger {
8091
}
8192

8293

94+
/// Creates a new 2D object by converting the values of the given one
95+
///
96+
/// - Parameter other: Another 2D object to convert
97+
init<Other>(_ other: Other)
98+
where Other: TwoDimensional,
99+
Other.Length: BinaryFloatingPoint
100+
{
101+
self.init(measurementX: Length.init(other.measurementX), measurementY: Length.init(other.measurementY))
102+
}
103+
104+
83105
/// Attempts to create a new 2D object by converting the values of the given one. If that can't be done (e.g. the
84106
/// other's bit width is larger than this one), `nil` is returned.
85107
///

0 commit comments

Comments
 (0)