@@ -52,7 +52,9 @@ extension AttributedString {
5252 andChanged changed: AttributedString . SingleAttributeTransformer < K > ,
5353 to attrStr: inout AttributedString ,
5454 key: K . Type
55- ) {
55+ )
56+ where
57+ K. Value : Sendable {
5658 if orig. range != changed. range || orig. attrName != changed. attrName {
5759 attrStr. _guts. removeAttributeValue ( forKey: K . self, in: orig. range. _bstringRange) // If the range changed, we need to remove from the old range first.
5860 }
@@ -63,7 +65,7 @@ extension AttributedString {
6365 andChanged changed: AttributedString . SingleAttributeTransformer < K > ,
6466 to attrStr: inout AttributedString ,
6567 key: K . Type
66- ) {
68+ ) where K . Value : Sendable {
6769 if orig. range != changed. range || orig. attrName != changed. attrName || orig. attr != changed. attr {
6870 if let newVal = changed. attr { // Then if there's a new value, we add it in.
6971 // 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 {
7880
7981@available ( macOS 12 , iOS 15 , tvOS 15 , watchOS 8 , * )
8082extension AttributedString {
83+ @preconcurrency
8184 public func transformingAttributes< K> (
8285 _ k: K . Type ,
8386 _ c: ( inout AttributedString . SingleAttributeTransformer < K > ) -> Void
84- ) -> AttributedString {
87+ ) -> AttributedString
88+ where
89+ K. Value : Sendable {
8590 let orig = AttributedString ( _guts)
8691 var copy = orig
8792 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 {
95100 return copy
96101 }
97102
103+ @preconcurrency
98104 public func transformingAttributes< K1, K2> (
99105 _ k: K1 . Type ,
100106 _ k2: K2 . Type ,
101107 _ c: ( inout AttributedString . SingleAttributeTransformer < K1 > ,
102108 inout AttributedString . SingleAttributeTransformer < K2 > ) -> Void
103- ) -> AttributedString {
109+ ) -> AttributedString
110+ where
111+ K1. Value : Sendable ,
112+ K2. Value : Sendable {
104113 let orig = AttributedString ( _guts)
105114 var copy = orig
106115 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 {
118127 return copy
119128 }
120129
130+ @preconcurrency
121131 public func transformingAttributes< K1, K2, K3> (
122132 _ k: K1 . Type ,
123133 _ k2: K2 . Type ,
124134 _ k3: K3 . Type ,
125135 _ c: ( inout AttributedString . SingleAttributeTransformer < K1 > ,
126136 inout AttributedString . SingleAttributeTransformer < K2 > ,
127137 inout AttributedString . SingleAttributeTransformer < K3 > ) -> Void
128- ) -> AttributedString {
138+ ) -> AttributedString
139+ where
140+ K1. Value : Sendable ,
141+ K2. Value : Sendable ,
142+ K3. Value : Sendable {
129143 let orig = AttributedString ( _guts)
130144 var copy = orig
131145 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 {
147161 return copy
148162 }
149163
164+ @preconcurrency
150165 public func transformingAttributes< K1, K2, K3, K4> (
151166 _ k: K1 . Type ,
152167 _ k2: K2 . Type ,
@@ -156,7 +171,12 @@ extension AttributedString {
156171 inout AttributedString . SingleAttributeTransformer < K2 > ,
157172 inout AttributedString . SingleAttributeTransformer < K3 > ,
158173 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 {
160180 let orig = AttributedString ( _guts)
161181 var copy = orig
162182 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 {
182202 return copy
183203 }
184204
205+ @preconcurrency
185206 public func transformingAttributes< K1, K2, K3, K4, K5> (
186207 _ k: K1 . Type ,
187208 _ k2: K2 . Type ,
@@ -193,7 +214,13 @@ extension AttributedString {
193214 inout AttributedString . SingleAttributeTransformer < K3 > ,
194215 inout AttributedString . SingleAttributeTransformer < K4 > ,
195216 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 {
197224 let orig = AttributedString ( _guts)
198225 var copy = orig
199226 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 {
226253
227254@available ( macOS 12 , iOS 15 , tvOS 15 , watchOS 8 , * )
228255extension AttributedString {
256+ @preconcurrency
229257 public func transformingAttributes< K> (
230258 _ k: KeyPath < AttributeDynamicLookup , K > ,
231259 _ c: ( inout AttributedString . SingleAttributeTransformer < K > ) -> Void
232- ) -> AttributedString {
260+ ) -> AttributedString
261+ where
262+ K. Value : Sendable {
233263 self . transformingAttributes ( K . self, c)
234264 }
235265
266+ @preconcurrency
236267 public func transformingAttributes< K1, K2> (
237268 _ k: KeyPath < AttributeDynamicLookup , K1 > ,
238269 _ k2: KeyPath < AttributeDynamicLookup , K2 > ,
239270 _ c: ( inout AttributedString . SingleAttributeTransformer < K1 > ,
240271 inout AttributedString . SingleAttributeTransformer < K2 > ) -> Void
241- ) -> AttributedString {
272+ ) -> AttributedString
273+ where
274+ K1. Value : Sendable ,
275+ K2. Value : Sendable {
242276 self . transformingAttributes ( K1 . self, K2 . self, c)
243277 }
244278
279+ @preconcurrency
245280 public func transformingAttributes< K1, K2, K3> (
246281 _ k: KeyPath < AttributeDynamicLookup , K1 > ,
247282 _ k2: KeyPath < AttributeDynamicLookup , K2 > ,
248283 _ k3: KeyPath < AttributeDynamicLookup , K3 > ,
249284 _ c: ( inout AttributedString . SingleAttributeTransformer < K1 > ,
250285 inout AttributedString . SingleAttributeTransformer < K2 > ,
251286 inout AttributedString . SingleAttributeTransformer < K3 > ) -> Void
252- ) -> AttributedString {
287+ ) -> AttributedString
288+ where
289+ K1. Value : Sendable ,
290+ K2. Value : Sendable ,
291+ K3. Value : Sendable {
253292 self . transformingAttributes ( K1 . self, K2 . self, K3 . self, c)
254293 }
255294
295+ @preconcurrency
256296 public func transformingAttributes< K1, K2, K3, K4> (
257297 _ k: KeyPath < AttributeDynamicLookup , K1 > ,
258298 _ k2: KeyPath < AttributeDynamicLookup , K2 > ,
@@ -262,10 +302,16 @@ extension AttributedString {
262302 inout AttributedString . SingleAttributeTransformer < K2 > ,
263303 inout AttributedString . SingleAttributeTransformer < K3 > ,
264304 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 {
266311 self . transformingAttributes ( K1 . self, K2 . self, K3 . self, K4 . self, c)
267312 }
268313
314+ @preconcurrency
269315 public func transformingAttributes< K1, K2, K3, K4, K5> (
270316 _ k: KeyPath < AttributeDynamicLookup , K1 > ,
271317 _ k2: KeyPath < AttributeDynamicLookup , K2 > ,
@@ -277,7 +323,13 @@ extension AttributedString {
277323 inout AttributedString . SingleAttributeTransformer < K3 > ,
278324 inout AttributedString . SingleAttributeTransformer < K4 > ,
279325 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 {
281333 self . transformingAttributes ( K1 . self, K2 . self, K3 . self, K4 . self, K5 . self, c)
282334 }
283335}
0 commit comments