@@ -52,7 +52,9 @@ extension AttributedString {
52
52
andChanged changed: AttributedString . SingleAttributeTransformer < K > ,
53
53
to attrStr: inout AttributedString ,
54
54
key: K . Type
55
- ) {
55
+ )
56
+ where
57
+ K. Value : Sendable {
56
58
if orig. range != changed. range || orig. attrName != changed. attrName {
57
59
attrStr. _guts. removeAttributeValue ( forKey: K . self, in: orig. range. _bstringRange) // If the range changed, we need to remove from the old range first.
58
60
}
@@ -63,7 +65,7 @@ extension AttributedString {
63
65
andChanged changed: AttributedString . SingleAttributeTransformer < K > ,
64
66
to attrStr: inout AttributedString ,
65
67
key: K . Type
66
- ) {
68
+ ) where K . Value : Sendable {
67
69
if orig. range != changed. range || orig. attrName != changed. attrName || orig. attr != changed. attr {
68
70
if let newVal = changed. attr { // Then if there's a new value, we add it in.
69
71
// Unfortunately, we can't use the attrStr[range].set() provided by the AttributedStringProtocol, because we *don't know* the new type statically!
@@ -78,10 +80,13 @@ extension AttributedString {
78
80
79
81
@available ( macOS 12 , iOS 15 , tvOS 15 , watchOS 8 , * )
80
82
extension AttributedString {
83
+ @preconcurrency
81
84
public func transformingAttributes< K> (
82
85
_ k: K . Type ,
83
86
_ c: ( inout AttributedString . SingleAttributeTransformer < K > ) -> Void
84
- ) -> AttributedString {
87
+ ) -> AttributedString
88
+ where
89
+ K. Value : Sendable {
85
90
let orig = AttributedString ( _guts)
86
91
var copy = orig
87
92
copy. ensureUniqueReference ( ) // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -95,12 +100,16 @@ extension AttributedString {
95
100
return copy
96
101
}
97
102
103
+ @preconcurrency
98
104
public func transformingAttributes< K1, K2> (
99
105
_ k: K1 . Type ,
100
106
_ k2: K2 . Type ,
101
107
_ c: ( inout AttributedString . SingleAttributeTransformer < K1 > ,
102
108
inout AttributedString . SingleAttributeTransformer < K2 > ) -> Void
103
- ) -> AttributedString {
109
+ ) -> AttributedString
110
+ where
111
+ K1. Value : Sendable ,
112
+ K2. Value : Sendable {
104
113
let orig = AttributedString ( _guts)
105
114
var copy = orig
106
115
copy. ensureUniqueReference ( ) // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -118,14 +127,19 @@ extension AttributedString {
118
127
return copy
119
128
}
120
129
130
+ @preconcurrency
121
131
public func transformingAttributes< K1, K2, K3> (
122
132
_ k: K1 . Type ,
123
133
_ k2: K2 . Type ,
124
134
_ k3: K3 . Type ,
125
135
_ c: ( inout AttributedString . SingleAttributeTransformer < K1 > ,
126
136
inout AttributedString . SingleAttributeTransformer < K2 > ,
127
137
inout AttributedString . SingleAttributeTransformer < K3 > ) -> Void
128
- ) -> AttributedString {
138
+ ) -> AttributedString
139
+ where
140
+ K1. Value : Sendable ,
141
+ K2. Value : Sendable ,
142
+ K3. Value : Sendable {
129
143
let orig = AttributedString ( _guts)
130
144
var copy = orig
131
145
copy. ensureUniqueReference ( ) // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -147,6 +161,7 @@ extension AttributedString {
147
161
return copy
148
162
}
149
163
164
+ @preconcurrency
150
165
public func transformingAttributes< K1, K2, K3, K4> (
151
166
_ k: K1 . Type ,
152
167
_ k2: K2 . Type ,
@@ -156,7 +171,12 @@ extension AttributedString {
156
171
inout AttributedString . SingleAttributeTransformer < K2 > ,
157
172
inout AttributedString . SingleAttributeTransformer < K3 > ,
158
173
inout AttributedString . SingleAttributeTransformer < K4 > ) -> Void
159
- ) -> AttributedString {
174
+ ) -> AttributedString
175
+ where
176
+ K1. Value : Sendable ,
177
+ K2. Value : Sendable ,
178
+ K3. Value : Sendable ,
179
+ K4. Value : Sendable {
160
180
let orig = AttributedString ( _guts)
161
181
var copy = orig
162
182
copy. ensureUniqueReference ( ) // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -182,6 +202,7 @@ extension AttributedString {
182
202
return copy
183
203
}
184
204
205
+ @preconcurrency
185
206
public func transformingAttributes< K1, K2, K3, K4, K5> (
186
207
_ k: K1 . Type ,
187
208
_ k2: K2 . Type ,
@@ -193,7 +214,13 @@ extension AttributedString {
193
214
inout AttributedString . SingleAttributeTransformer < K3 > ,
194
215
inout AttributedString . SingleAttributeTransformer < K4 > ,
195
216
inout AttributedString . SingleAttributeTransformer < K5 > ) -> Void
196
- ) -> AttributedString {
217
+ ) -> AttributedString
218
+ where
219
+ K1. Value : Sendable ,
220
+ K2. Value : Sendable ,
221
+ K3. Value : Sendable ,
222
+ K4. Value : Sendable ,
223
+ K5. Value : Sendable {
197
224
let orig = AttributedString ( _guts)
198
225
var copy = orig
199
226
copy. ensureUniqueReference ( ) // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -226,33 +253,46 @@ extension AttributedString {
226
253
227
254
@available ( macOS 12 , iOS 15 , tvOS 15 , watchOS 8 , * )
228
255
extension AttributedString {
256
+ @preconcurrency
229
257
public func transformingAttributes< K> (
230
258
_ k: KeyPath < AttributeDynamicLookup , K > ,
231
259
_ c: ( inout AttributedString . SingleAttributeTransformer < K > ) -> Void
232
- ) -> AttributedString {
260
+ ) -> AttributedString
261
+ where
262
+ K. Value : Sendable {
233
263
self . transformingAttributes ( K . self, c)
234
264
}
235
265
266
+ @preconcurrency
236
267
public func transformingAttributes< K1, K2> (
237
268
_ k: KeyPath < AttributeDynamicLookup , K1 > ,
238
269
_ k2: KeyPath < AttributeDynamicLookup , K2 > ,
239
270
_ c: ( inout AttributedString . SingleAttributeTransformer < K1 > ,
240
271
inout AttributedString . SingleAttributeTransformer < K2 > ) -> Void
241
- ) -> AttributedString {
272
+ ) -> AttributedString
273
+ where
274
+ K1. Value : Sendable ,
275
+ K2. Value : Sendable {
242
276
self . transformingAttributes ( K1 . self, K2 . self, c)
243
277
}
244
278
279
+ @preconcurrency
245
280
public func transformingAttributes< K1, K2, K3> (
246
281
_ k: KeyPath < AttributeDynamicLookup , K1 > ,
247
282
_ k2: KeyPath < AttributeDynamicLookup , K2 > ,
248
283
_ k3: KeyPath < AttributeDynamicLookup , K3 > ,
249
284
_ c: ( inout AttributedString . SingleAttributeTransformer < K1 > ,
250
285
inout AttributedString . SingleAttributeTransformer < K2 > ,
251
286
inout AttributedString . SingleAttributeTransformer < K3 > ) -> Void
252
- ) -> AttributedString {
287
+ ) -> AttributedString
288
+ where
289
+ K1. Value : Sendable ,
290
+ K2. Value : Sendable ,
291
+ K3. Value : Sendable {
253
292
self . transformingAttributes ( K1 . self, K2 . self, K3 . self, c)
254
293
}
255
294
295
+ @preconcurrency
256
296
public func transformingAttributes< K1, K2, K3, K4> (
257
297
_ k: KeyPath < AttributeDynamicLookup , K1 > ,
258
298
_ k2: KeyPath < AttributeDynamicLookup , K2 > ,
@@ -262,10 +302,16 @@ extension AttributedString {
262
302
inout AttributedString . SingleAttributeTransformer < K2 > ,
263
303
inout AttributedString . SingleAttributeTransformer < K3 > ,
264
304
inout AttributedString . SingleAttributeTransformer < K4 > ) -> Void
265
- ) -> AttributedString {
305
+ ) -> AttributedString
306
+ where
307
+ K1. Value : Sendable ,
308
+ K2. Value : Sendable ,
309
+ K3. Value : Sendable ,
310
+ K4. Value : Sendable {
266
311
self . transformingAttributes ( K1 . self, K2 . self, K3 . self, K4 . self, c)
267
312
}
268
313
314
+ @preconcurrency
269
315
public func transformingAttributes< K1, K2, K3, K4, K5> (
270
316
_ k: KeyPath < AttributeDynamicLookup , K1 > ,
271
317
_ k2: KeyPath < AttributeDynamicLookup , K2 > ,
@@ -277,7 +323,13 @@ extension AttributedString {
277
323
inout AttributedString . SingleAttributeTransformer < K3 > ,
278
324
inout AttributedString . SingleAttributeTransformer < K4 > ,
279
325
inout AttributedString . SingleAttributeTransformer < K5 > ) -> Void
280
- ) -> AttributedString {
326
+ ) -> AttributedString
327
+ where
328
+ K1. Value : Sendable ,
329
+ K2. Value : Sendable ,
330
+ K3. Value : Sendable ,
331
+ K4. Value : Sendable ,
332
+ K5. Value : Sendable {
281
333
self . transformingAttributes ( K1 . self, K2 . self, K3 . self, K4 . self, K5 . self, c)
282
334
}
283
335
}
0 commit comments