Skip to content

Commit 3b44f10

Browse files
authored
Merge pull request #31318 from valeriyvan/patch-7
2 parents c7aa067 + a60e851 commit 3b44f10

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

docs/Literals.rst

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,30 @@ The ExpressibleByStringLiteral Protocol
3636
Here is the ExpressibleByStringLiteral protocol as defined in the standard
3737
library's CompilerProtocols.swift::
3838

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.
4152
public protocol ExpressibleByStringLiteral
4253
: ExpressibleByExtendedGraphemeClusterLiteral {
4354

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.
4663
init(stringLiteral value: StringLiteralType)
4764
}
4865

0 commit comments

Comments
 (0)