Skip to content

Commit 4c5ebbf

Browse files
committed
Define primary associated type for RegexComponent.
This defines `RegexComponent<Match>` using the syntax pitched in https://forums.swift.org/t/pitch-2-light-weight-same-type-requirement-syntax/55081.
1 parent 85c7d90 commit 4c5ebbf

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ let package = Package(
4444
dependencies: ["_MatchingEngine", "_CUnicode"],
4545
swiftSettings: [
4646
.unsafeFlags(["-enable-library-evolution"]),
47-
.unsafeFlags(["-Xfrontend", "-enable-experimental-pairwise-build-block"])
47+
.unsafeFlags(["-Xfrontend", "-enable-experimental-pairwise-build-block"]),
48+
.unsafeFlags(["-Xfrontend", "-enable-parameterized-protocol-types"])
4849
]),
4950
.testTarget(
5051
name: "RegexTests",

Sources/_StringProcessing/RegexDSL/Core.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
import _MatchingEngine
1313

14-
1514
/// A type that represents a regular expression.
16-
public protocol RegexComponent {
17-
associatedtype Match
15+
public protocol RegexComponent<Match> {
1816
var regex: Regex<Match> { get }
1917
}
2018

@@ -84,9 +82,9 @@ public struct Regex<Match>: RegexComponent {
8482
self = content.regex
8583
}
8684

87-
public init<Content: RegexComponent>(
88-
@RegexComponentBuilder _ content: () -> Content
89-
) where Content.Match == Match {
85+
public init(
86+
@RegexComponentBuilder _ content: () -> some RegexComponent<Match>
87+
) {
9088
self.init(content())
9189
}
9290

0 commit comments

Comments
 (0)