Contents

transform(updating:body:)

Tracks the location of the provided range throughout the mutation closure, updating the provided range to one that represents the same effective locations after the mutation.

Declaration

mutating func transform<E>(updating range: inout Range<AttributedString.Index>, body: (inout AttributedString) throws(E) -> Void) throws(E) where E : Error

Parameters

  • range:

    A range to track throughout the body closure.

  • body:

    A mutating operation, or set of operations, to perform on the value of self. The value of self is provided to the closure as an inout AttributedString that the closure should mutate directly. Do not capture the value of self in the provided closure - the closure should mutate the provided inout copy.

Discussion

If updating the provided range is not possible (tracking failed) then this function will fatal error. Use the Optional-returning variants to provide custom fallback behavior.