Skip to content

Commit 5653576

Browse files
committed
Fixes for Swift 6
1 parent 662e816 commit 5653576

File tree

5 files changed

+46
-36
lines changed

5 files changed

+46
-36
lines changed

Advent/Sources/Conversion/RawRepresentable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
extension RawRepresentable {
2+
extension RawRepresentable where RawValue: Sendable {
33

44
public init(_ rawValue: RawValue) throws {
55

@@ -11,7 +11,7 @@ extension RawRepresentable {
1111
}
1212
}
1313

14-
public struct UnexpectedRawValue<RawValue>: Error {
14+
public struct UnexpectedRawValue<RawValue: Sendable>: Error {
1515
let rawValue: RawValue
1616
public init(rawValue: RawValue) {
1717
self.rawValue = rawValue

Advent/Sources/Geometry/Angle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public struct Angle {
1515

1616
extension Angle {
1717

18-
public static let zero = Angle(radians: 0)
18+
public static var zero: Angle { Angle(radians: 0) }
1919

2020
public init(degrees: Double) {
2121
self.init(radians: degrees/360 * .tau)

Advent/Sources/Geometry/Grid.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ extension Grid where Location == Position2D<Int>, Tile: RawRepresentable {
158158
/// If you have an array of array of Ints this works! :D
159159
///
160160
/// - Parameter characters: The sequence of sequences of raw values.
161-
public init<Rows, Columns, RawValue>(
161+
public init<Rows, Columns, RawValue: Sendable>(
162162
origin: Origin = .bottomLeft,
163163
rawValues: Rows
164164
) throws

Advent/Sources/Strings/Regex.swift

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,23 @@ extension Regex {
1919

2020
extension TryCapture where Output == (Substring, Int) {
2121

22-
public static let integer = TryCapture {
23-
OneOrMore(.digit)
24-
} transform: {
25-
Int($0)
22+
public static var integer: Self {
23+
TryCapture {
24+
OneOrMore(.digit)
25+
} transform: {
26+
Int($0)
27+
}
2628
}
2729
}
2830

2931
extension TryCapture where Output == (Substring, Character) {
3032

31-
public static let character = TryCapture {
32-
One(.any)
33-
} transform: {
34-
$0.first
33+
public static var character: Self {
34+
TryCapture {
35+
One(.any)
36+
} transform: {
37+
$0.first
38+
}
3539
}
3640
}
3741

@@ -49,16 +53,20 @@ extension TryCapture {
4953

5054
extension Capture where Output == (Substring, String) {
5155

52-
public static let string = Capture {
53-
OneOrMore(.any)
54-
} transform: {
55-
String($0)
56+
public static var string: Self {
57+
Capture {
58+
OneOrMore(.any)
59+
} transform: {
60+
String($0)
61+
}
5662
}
5763

58-
public static let alpha = Capture {
59-
OneOrMore(.word)
60-
} transform: {
61-
String($0)
64+
public static var alpha: Self {
65+
Capture {
66+
OneOrMore(.word)
67+
} transform: {
68+
String($0)
69+
}
6270
}
6371
}
6472

Year2015/Sources/Day06.swift

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,26 @@ extension Day06 {
100100
case off = "turn off"
101101
}
102102

103-
private static let regex = Regex {
104-
TryCapture {
105-
ChoiceOf {
106-
"turn on"
107-
"toggle"
108-
"turn off"
103+
private static var regex: Regex<(Substring, Day06.Instruction.Kind, Int, Int, Int, Int)> {
104+
Regex {
105+
TryCapture {
106+
ChoiceOf {
107+
"turn on"
108+
"toggle"
109+
"turn off"
110+
}
111+
} transform: {
112+
Kind(rawValue: String($0))
109113
}
110-
} transform: {
111-
Kind(rawValue: String($0))
114+
" "
115+
TryCapture.integer
116+
","
117+
TryCapture.integer
118+
" through "
119+
TryCapture.integer
120+
","
121+
TryCapture.integer
112122
}
113-
" "
114-
TryCapture.integer
115-
","
116-
TryCapture.integer
117-
" through "
118-
TryCapture.integer
119-
","
120-
TryCapture.integer
121123
}
122124

123125
let kind: Kind

0 commit comments

Comments
 (0)