Module similar::utils[][src]

Utilities for common diff related operations.

This module provides specialized utilities and simplified diff operations for common operations. It’s useful when you want to work with text diffs and you’re interested in getting vectors of these changes directly.

Slice Remapping

When working with TextDiff it’s common that one takes advantage of the built-in tokenization of the differ. This for instance lets you do grapheme level diffs. This is implemented by the differ generating rather small slices of strings and running a diff algorithm over them.

The downside of this is that all the DiffOp objects produced by the diffing algorithm encode operations on these rather small slices. For a lot of use cases this is not what one wants which can make this very inconvenient. This module provides a TextDiffRemapper which lets you map from the ranges that the TextDiff returns to the original input strings. For more information see TextDiffRemapper.

Simple Diff Functions

This module provides a range of common test diff functions that will produce vectors of (change_tag, value) tuples. They will automatically optimize towards returning the most useful slice that one would expect for the type of diff performed.

Structs

TextDiffRemapper

A remapper that can remap diff ops to the original slices.

Functions

diff_chars

Shortcut for making a character level diff.

diff_graphemes

Shortcut for making a grapheme level diff.

diff_lines

Shortcut for making a line diff.

diff_slices

Shortcut for diffing two slices.

diff_unicode_words

Shortcut for making a unicode word level diff.

diff_words

Shortcut for making a word level diff.