Skip to content

Commit 0486f1a

Browse files
committed
Swift Utils: make StringRef be ExpressibleByStringLiteral
1 parent 7387f85 commit 0486f1a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ public extension NoReflectionChildren {
7979
// StringRef
8080
//===----------------------------------------------------------------------===//
8181

82-
public struct StringRef : CustomStringConvertible, NoReflectionChildren {
82+
public struct StringRef : CustomStringConvertible, NoReflectionChildren, ExpressibleByStringLiteral {
8383
public let _bridged: BridgedStringRef
8484

8585
public init(bridged: BridgedStringRef) { self._bridged = bridged }
8686

87+
public init(stringLiteral: StaticString) {
88+
self._bridged = BridgedStringRef(data: stringLiteral.utf8Start, count: stringLiteral.utf8CodeUnitCount)
89+
}
90+
8791
public var string: String { String(_bridged) }
8892
public var description: String { string }
8993

0 commit comments

Comments
 (0)