1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
//! This crate implements diffing utilities. It attempts to provide an abstraction //! interface over different types of diffing algorithms. It's based on the //! the diff algorithm implementations of [pijul](https://pijul.org/). //! //! ```rust //! # #[cfg(feature = "text")] { //! use similar::text::{ChangeTag, TextDiff}; //! //! let diff = TextDiff::from_lines( //! "Hello World\nThis is the second line.\nThis is the third.", //! "Hallo Welt\nThis is the second line.\nThis is life.\nMoar and more", //! ); //! //! for op in diff.ops() { //! for change in diff.iter_changes(op) { //! let sign = match change.tag() { //! ChangeTag::Delete => "-", //! ChangeTag::Insert => "+", //! ChangeTag::Equal => " ", //! }; //! print!("{}{}", sign, change.value()); //! } //! } //! # } //! ``` //! //! ## Functionality //! //! * [`algorithms`]: This implements the different types of diffing algorithms. //! It provides both low level access to the algorithms with the minimal //! trait bounds necessary, as well as a generic interface. //! * [`text`]: This extends the general diffing functionality to text (and more //! specifically line) based diff operations. //! //! ## Features //! //! The crate by default does not have any dependencies however for some use //! cases it's useful to pull in extra functionality. Likewise you can turn //! off some functionality. //! //! * `unicode`: when this feature is enabled the text diffing functionality //! gains the ability to diff on a grapheme instead of character level. This //! is particularly useful when working with text containing emojis. //! * `text`: this feature is enabled by default and enables the [`text`] module. //! If the crate is used without default features it's removed. pub mod algorithms; pub mod text;