From 98f138ab76c3081a698adda7ce0a76882ad43d4e Mon Sep 17 00:00:00 2001 From: Michael Ilseman Date: Mon, 25 Apr 2022 15:32:12 -0600 Subject: [PATCH 1/2] API stubs for casting and named captures --- .../Regex/AnyRegexOutput.swift | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Sources/_StringProcessing/Regex/AnyRegexOutput.swift b/Sources/_StringProcessing/Regex/AnyRegexOutput.swift index 0d018aa81..72ae79ec9 100644 --- a/Sources/_StringProcessing/Regex/AnyRegexOutput.swift +++ b/Sources/_StringProcessing/Regex/AnyRegexOutput.swift @@ -205,3 +205,28 @@ extension Regex.Match where Output == AnyRegexOutput { fatalError("FIXME: Not implemented") } } + +@available(SwiftStdlib 5.7, *) +extension Regex where Output == AnyRegexOutput { + /// Returns whether a named-capture with `name` exists + public func contains(namedCapture name: String) -> Bool { + fatalError("FIXME: not implemented") + } + + /// Creates a type-erased regex from an existing regex. + /// + /// Use this initializer to fit a regex with strongly typed captures into the + /// use site of a dynamic regex, i.e. one that was created from a string. + public init(_ match: Regex) { + fatalError("FIXME: Not implemented") + } + + /// Returns a typed regex by converting the underlying types. + /// + /// - Parameter type: The expected output type. + /// - Returns: A regex generic over the output type if the underlying types can be converted. + /// Returns `nil` otherwise. + public func `as`(_ type: Output.Type) -> Regex? { + fatalError("FIXME: Not implemented") + } +} From 3b20e116d5f48ba9757d40f9c0ef012fcccc0c01 Mon Sep 17 00:00:00 2001 From: Michael Ilseman Date: Mon, 25 Apr 2022 18:53:54 -0600 Subject: [PATCH 2/2] Update Sources/_StringProcessing/Regex/AnyRegexOutput.swift Co-authored-by: Richard Wei --- Sources/_StringProcessing/Regex/AnyRegexOutput.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/_StringProcessing/Regex/AnyRegexOutput.swift b/Sources/_StringProcessing/Regex/AnyRegexOutput.swift index 72ae79ec9..295ef97fc 100644 --- a/Sources/_StringProcessing/Regex/AnyRegexOutput.swift +++ b/Sources/_StringProcessing/Regex/AnyRegexOutput.swift @@ -209,7 +209,7 @@ extension Regex.Match where Output == AnyRegexOutput { @available(SwiftStdlib 5.7, *) extension Regex where Output == AnyRegexOutput { /// Returns whether a named-capture with `name` exists - public func contains(namedCapture name: String) -> Bool { + public func contains(captureNamed name: String) -> Bool { fatalError("FIXME: not implemented") }