Closed
Description
Previous ID | SR-2303 |
Radar | None |
Original Reporter | @jtbandes |
Type | Improvement |
Status | Resolved |
Resolution | Done |
Additional Detail from JIRA
Votes | 1 |
Component/s | Standard Library |
Labels | Improvement, LanguageFeatureRequest |
Assignee | @beccadax |
Priority | Medium |
md5: d86f9995a0b9dc90aad8b59b81c4bab2
relates to:
- SR-1260 ExpressibleByStringInterpolation: can't distinguish between literal components and String arguments
- SR-3969 Improve ExpressibleByStringInterpolation
Issue Description:
It's desirable for types conforming to ExpressibleByStringInterpolation
to be able to restrict the kinds of values that can be used in string interpolation.
The following example is a simplified version of brentdax (JIRA User)'s example from the swift-evolution thread:
// We want LocalizedString to be formed from a string interpolation;
// only LocalizedStringConvertible values should be allowed as interpolated values.
protocol LocalizedStringConvertible { ... }
struct LocalizedString { ... }
extension LocalizedString: ExpressibleByStringInterpolation {
init(stringInterpolation segments: LocalizedString...) { }
init(stringInterpolationSegment value: LocalizedStringConvertible) { ... }
// no init<T>(stringInterpolationSegment:) is provided; only LocalizedStringConvertible values are valid
}