|
1 | 1 | //! Tools for finding and manipulating differences between files |
2 | 2 | //! |
3 | | -//! ## Overview |
| 3 | +//! # Overview |
4 | 4 | //! |
5 | 5 | //! This library is intended to be a collection of tools used to find and |
6 | | -//! manipulate differences between files inspired by [LibXDiff] and [GNU |
7 | | -//! Diffutils]. Version control systems like [Git] and [Mercurial] generally |
8 | | -//! communicate differences between two versions of a file using a `diff` or |
9 | | -//! `patch`. |
| 6 | +//! manipulate differences between files or arbitrary data inspired by |
| 7 | +//! [LibXDiff] and [GNU Diffutils]. Version control systems like [Git] and |
| 8 | +//! [Mercurial] generallycommunicate differences between two versions of a |
| 9 | +//! file using a `diff` or `patch`. |
10 | 10 | //! |
11 | 11 | //! The current diff implementation is based on the [Myers' diff algorithm]. |
12 | 12 | //! |
| 13 | +//! ## Supported features |
| 14 | +//! |
| 15 | +//! | Feature | UTF-8 strings | non-UTF-8 string | Arbitrary types (that implement `Eq + Hash`) | |
| 16 | +//! |------------------|---------------|------------------|----------------------------------------------| |
| 17 | +//! | Creating a patch | ✅ | ✅ | | |
| 18 | +//! | Applying a patch | ✅ | ✅ | | |
| 19 | +//! | 3-way merge | ✅ | ✅ | ✅ | |
| 20 | +//! |
| 21 | +//! "Arbitrary types" means "any type that implements `Eq + Hash`".<br/> |
| 22 | +//! Supporting patches for arbitrary types would not be very helpful, since |
| 23 | +//! there is no standardized way of formatting them. |
| 24 | +//! |
13 | 25 | //! ## UTF-8 and Non-UTF-8 |
14 | 26 | //! |
15 | 27 | //! This library has support for working with both utf8 and non-utf8 texts. |
|
198 | 210 | //! assert_eq!(merge(original, a, b).unwrap_err(), expected); |
199 | 211 | //! ``` |
200 | 212 | //! |
| 213 | +//! It is possible to perform 3-way merges between collections of arbitrary |
| 214 | +//! types `T` as long as `T: Eq + Hash`. |
| 215 | +//! ``` |
| 216 | +//! use diffy::merge_custom; |
| 217 | +//! |
| 218 | +//! let original = [1,2,3,4,5, 6]; |
| 219 | +//! let a = [1,2,3,4,5,100,6]; |
| 220 | +//! let b = [1, 3,4,5, 6]; |
| 221 | +//! let expected = [1, 3,4,5,100,6]; |
| 222 | +//! |
| 223 | +//! let result = merge_custom(&original, &a, &b).unwrap(); |
| 224 | +//! let result_owned: Vec<i32> = result.iter().map(|r| **r).collect(); |
| 225 | +//! assert_eq!(result_owned, expected); |
| 226 | +//! ``` |
| 227 | +//! |
| 228 | +//! |
201 | 229 | //! [LibXDiff]: http://www.xmailserver.org/xdiff-lib.html |
202 | 230 | //! [Myers' diff algorithm]: http://www.xmailserver.org/diff2.pdf |
203 | 231 | //! [GNU Diffutils]: https://www.gnu.org/software/diffutils/ |
|
0 commit comments