Skip to content

Instantly share code, notes, and snippets.

@laevandus

laevandus/Interpolation.swift Secret

Created Mar 22, 2021
Embed
What would you like to do?
struct Entry: ExpressibleByStringInterpolation {
// typealias StringInterpolation = EntryInterpolation
private(set) var value: String
init(stringLiteral value: String) {
self.value = value
}
init(stringInterpolation: EntryInterpolation) {
self.value = stringInterpolation.values.joined()
}
}
struct EntryInterpolation: StringInterpolationProtocol {
private(set) var values: [String]
init(literalCapacity: Int, interpolationCount: Int) {
self.values = []
}
mutating func appendLiteral(_ literal: StringLiteralType) {
values.append(literal)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment