@@ -36,13 +36,30 @@ The ExpressibleByStringLiteral Protocol
36
36
Here is the ExpressibleByStringLiteral protocol as defined in the standard
37
37
library's CompilerProtocols.swift::
38
38
39
- // NOTE: the compiler has builtin knowledge of this protocol
40
- // Conforming types can be initialized with arbitrary string literals.
39
+ /// A type that can be initialized with a string literal.
40
+ ///
41
+ /// The `String` and `StaticString` types conform to the
42
+ /// `ExpressibleByStringLiteral` protocol. You can initialize a variable or
43
+ /// constant of either of these types using a string literal of any length.
44
+ ///
45
+ /// let picnicGuest = "Deserving porcupine"
46
+ ///
47
+ /// Conforming to ExpressibleByStringLiteral
48
+ /// ========================================
49
+ ///
50
+ /// To add `ExpressibleByStringLiteral` conformance to your custom type,
51
+ /// implement the required initializer.
41
52
public protocol ExpressibleByStringLiteral
42
53
: ExpressibleByExtendedGraphemeClusterLiteral {
43
54
44
- typealias StringLiteralType : _ExpressibleByBuiltinStringLiteral
45
- // Create an instance initialized to `value`.
55
+ /// A type that represents a string literal.
56
+ ///
57
+ /// Valid types for `StringLiteralType` are `String` and `StaticString`.
58
+ associatedtype StringLiteralType: _ExpressibleByBuiltinStringLiteral
59
+
60
+ /// Creates an instance initialized to the given string value.
61
+ ///
62
+ /// - Parameter value: The value of the new instance.
46
63
init(stringLiteral value: StringLiteralType)
47
64
}
48
65
0 commit comments