Skip to content

Use inits instead of as methods #448

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 6 commits into from
May 31, 2022
Merged

Use inits instead of as methods #448

merged 6 commits into from
May 31, 2022

Conversation

milseman
Copy link
Member

No description provided.

@milseman milseman requested a review from Azoy May 27, 2022 14:34
@milseman
Copy link
Member Author

@swift-ci please test

/// Use this initializer to create a strongly typed regex from
/// one that was created from a string. Returns `nil` if the types
/// don't match.
public init?(_ dynamic: Regex<AnyRegexOutput>) {
Copy link
Member

@natecook1000 natecook1000 May 27, 2022

Choose a reason for hiding this comment

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

It feels like we should have an as: Output.Type = Output.self parameter to match the run-time string-based initializer. e.g.

let pattern = "a+(b+)c+"
let a = try Regex(pattern, as: (Substring, Substring).self))
let b: Regex<(Substring, Substring)> = try Regex(pattern)

let dynamic = try Regex(pattern)
let c = Regex(dynamic, as: (Substring, Substring).self)!
let d: Regex<(Substring, Substring)> = Regex(dynamic)!

Copy link
Member Author

Choose a reason for hiding this comment

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

Argh that syntax highlighting. Any ideas for a better argument name than dynamic?

@milseman
Copy link
Member Author

@swift-ci please test

@milseman milseman merged commit d9869ea into swiftlang:main May 31, 2022
milseman added a commit to milseman/swift-experimental-string-processing that referenced this pull request May 31, 2022
Use inits instead of as methods

Add ARO tests
milseman added a commit that referenced this pull request Jun 7, 2022
Use inits instead of as methods

Add ARO tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants