Module similar::algorithms[][src]

Various diff (longest common subsequence) algorithms.

The implementations of the algorithms in this module are relatively low level and expose the most generic bounds possible for the algorithm. To use them you would typically use the higher level API if possible but direct access to these algorithms can be useful in some cases.

All these algorithms provide a diff function which takes two indexable objects (for instance slices) and a DiffHook. As the diff is generated the diff hook is invoked. Note that the diff hook does not get access to the actual values but only the indexes. This is why the diff hook is not used outside of the raw algorithm implementations as for most situations access to the values is useful of required.

Most of the crate operates on the Algorithm enum which abstracts over the different algorithms.

Modules

myers

Myers' diff algorithm.

patience

Patience diff algorithm.

Structs

Capture

A DiffHook that captures all diff operations.

Replace

A DiffHook that combines deletions and insertions to give blocks of maximal length, and replacements when appropriate.

Enums

Algorithm

An enum representing a diffing algorithm.

DiffOp

Utility enum to capture a diff operation.

DiffTag

The tag of a diff operation.

Traits

DiffHook

A trait for reacting to an edit script from the "old" version to the "new" version.

Functions

capture_diff

Creates a diff between old and new with the given algorithm capturing the ops.

capture_diff_slices

Creates a diff between old and new with the given algorithm capturing the ops.

diff

Creates a diff between old and new with the given algorithm.

diff_slices

Shortcut for diffing slices with a specific algorithm.

group_diff_ops

Isolate change clusters by eliminating ranges with no changes.