Document grapheme diffing and fix from_chars/from_words
This commit is contained in:
parent
1b96739cc3
commit
93ded2e62c
2 changed files with 19 additions and 3 deletions
18
src/lib.rs
18
src/lib.rs
|
|
@ -1,13 +1,29 @@
|
||||||
//! This crate implements diffing utilities. It attempts to provide an abstraction
|
//! This crate implements diffing utilities. It attempts to provide an abstraction
|
||||||
//! interface over different types of diffing algorithms. It's based on the
|
//! interface over different types of diffing algorithms. It's based on the
|
||||||
//! the diff algorithm implementations of [pijul](https://pijul.org/).
|
//! the diff algorithm implementations of [pijul](https://pijul.org/).
|
||||||
|
|
||||||
|
//! ```rust
|
||||||
|
//! use similar::text::TextDiff;
|
||||||
|
//! # let old_text = "";
|
||||||
|
//! # let new_text = "";
|
||||||
|
//! let diff = TextDiff::from_chars("Hello World", "Hallo Welt");
|
||||||
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! The crate is split into two modules:
|
//! ## Functionality
|
||||||
//!
|
//!
|
||||||
//! * [`algorithms`]: This implements the different types of diffing algorithms.
|
//! * [`algorithms`]: This implements the different types of diffing algorithms.
|
||||||
//! It provides both low level access to the algorithms with the minimal
|
//! It provides both low level access to the algorithms with the minimal
|
||||||
//! trait bounds necessary, as well as a generic interface.
|
//! trait bounds necessary, as well as a generic interface.
|
||||||
//! * [`text`]: This extends the general diffing functionality to text (and more
|
//! * [`text`]: This extends the general diffing functionality to text (and more
|
||||||
//! specifically line) based diff operations.
|
//! specifically line) based diff operations.
|
||||||
|
//!
|
||||||
|
//! ## Optional Features
|
||||||
|
//!
|
||||||
|
//! The crate by default does not have any dependencies however for some use
|
||||||
|
//! cases it's useful to pull in extra 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.
|
||||||
pub mod algorithms;
|
pub mod algorithms;
|
||||||
pub mod text;
|
pub mod text;
|
||||||
|
|
|
||||||
|
|
@ -256,12 +256,12 @@ impl<'old, 'new, 'bufs> TextDiff<'old, 'new, 'bufs> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a diff of words.
|
/// Creates a diff of words.
|
||||||
pub fn from_words(&self, old: &'old str, new: &'new str) -> TextDiff<'old, 'new, 'bufs> {
|
pub fn from_words(old: &'old str, new: &'new str) -> TextDiff<'old, 'new, 'bufs> {
|
||||||
Self::configure().diff_words(old, new)
|
Self::configure().diff_words(old, new)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a diff of chars.
|
/// Creates a diff of chars.
|
||||||
pub fn from_chars(&self, old: &'old str, new: &'new str) -> TextDiff<'old, 'new, 'bufs> {
|
pub fn from_chars(old: &'old str, new: &'new str) -> TextDiff<'old, 'new, 'bufs> {
|
||||||
Self::configure().diff_chars(old, new)
|
Self::configure().diff_chars(old, new)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue