Instance MethodFoundationEssentials
transform(updating:body:)
mutating func transform<E>(updating ranges: inout [Range<AttributedString.Index>], body: (inout AttributedString) throws(E) -> Void) throws(E) where E : Error
Parameters
rangesA list of ranges to track throughout the
bodyclosure. The updated array (after the function is called) is guaranteed to be the same size as the provided array. Updated ranges are located at the same indices as their respective original ranges in the inputrangesarray.bodyA mutating operation, or set of operations, to perform on the value of
self. The value ofselfis provided to the closure as aninout AttributedStringthat the closure should mutate directly. Do not capture the value ofselfin the provided closure - the closure should mutate the providedinoutcopy.
Discussion
If updating the provided ranges is not possible (tracking failed) then this function will fatal error. Use the Optional-returning variants to provide custom fallback behavior.