Skip to content

Use some RegexComponent in variadic inits #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Sources/RegexBuilder/DSL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
@available(SwiftStdlib 5.7, *)
extension Regex {
/// Creates a regular expression using a RegexBuilder closure.
public init<Content: RegexComponent>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this break ABI? Isn't some RegexComponent<Output> in the closure return type going to be an opaque return type, not a generic parameter on the parent declaration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular change is just a syntactic transformation of the original. You can get into trouble with multiple generic parameters, since the order is important to the ABI, but luckily all of those are @_alwaysEmitIntoClient. (This one should probably be that as well, tbh.)

@RegexComponentBuilder _ content: () -> Content
) where Content.RegexOutput == Output {
public init(
@RegexComponentBuilder _ content: () -> some RegexComponent<Output>
) {
self = content().regex
}
}
Expand Down Expand Up @@ -91,9 +91,9 @@ public struct One<Output>: RegexComponent {
public var regex: Regex<Output>

/// Creates a regex component that matches the given component exactly once.
public init<Component: RegexComponent>(
_ component: Component
) where Component.RegexOutput == Output {
public init(
_ component: some RegexComponent<Output>
) {
self.regex = component.regex
}
}
Expand Down
2,729 changes: 1,466 additions & 1,263 deletions Sources/RegexBuilder/Variadics.swift

Large diffs are not rendered by default.

Loading