Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make ExpressibleByStringLiteral tolerable
// If you want types initializable from String literals
// but don't want to implement three separate initializers.
extension ExpressibleByUnicodeScalarLiteral where Self: ExpressibleByStringLiteral, Self.StringLiteralType == String {
public init(unicodeScalarLiteral value: String) {
self.init(stringLiteral: value)
}
}
extension ExpressibleByExtendedGraphemeClusterLiteral where Self: ExpressibleByStringLiteral, Self.StringLiteralType == String {
public init(extendedGraphemeClusterLiteral value: String) {
self.init(stringLiteral: value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment