Name Description Size Coverage
algorithms -
common.rs 5254 -
deadline_support.rs 1073 -
iter.rs The various iterators this crate provides. These iterators are not a very stable interface and you really should avoid considering them to be concrete types. A lot of the iterators in this crate use `impl Iterator` for this reason but restrictions in the language don't allow this to be used in all places on the versions of rust this crate wants to compile for. 6179 -
lib.rs 7966 -
snapshots -
text -
types.rs 15828 -
udiff.rs This module provides unified diff functionality. It is available for as long as the `text` feature is enabled which is enabled by default: ```rust use similar::TextDiff; # let old_text = ""; # let new_text = ""; let text_diff = TextDiff::from_lines(old_text, new_text); print!("{}", text_diff .unified_diff() .context_radius(10) .header("old_file", "new_file")); ``` # Unicode vs Bytes The [`UnifiedDiff`] type supports both unicode and byte diffs for all types compatible with [`DiffableStr`]. You can pick between the two versions by using the [`Display`](std::fmt::Display) implementation or [`UnifiedDiff`] or [`UnifiedDiff::to_writer`]. The former uses [`DiffableStr::to_string_lossy`], the latter uses [`DiffableStr::as_bytes`] for each line. 11523 -
utils.rs 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. 13836 -