Skip to content

Commit b5b055a

Browse files
committed
Swift Utils: make StringRef matchable in patterns
By adding a `~=` operator with `StaticString`
1 parent ecbcacd commit b5b055a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public struct StringRef : CustomStringConvertible, NoReflectionChildren {
7676
}
7777

7878
public static func !=(lhs: StringRef, rhs: StaticString) -> Bool { !(lhs == rhs) }
79+
80+
public static func ~=(pattern: StaticString, value: StringRef) -> Bool { value == pattern }
7981
}
8082

8183
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)