Conforming CollectionDifference<Character> to LosslessStringConvertible

Because CollectionDifference.Change relies on index offsets, round‐trip serialization becomes a crash risk as soon as the serialized data passes outside the application’s memory. Most use cases for a LosslessStringConvertible conformance would be dangerous. See the following thread and its links for more information:

If you want to communicate string differences safely, you should split on some stable character like a line break, and then perform the differences on the resulting array of strings. Then even if the representation of any of the component strings changes, your overall data remains intact.

1 Like