Remove text utility functions in anticipation of API change

This commit is contained in:
Armin Ronacher 2021-01-23 22:07:56 +01:00
parent ca19caddc2
commit c9b0aa2eef
2 changed files with 2 additions and 45 deletions

View file

@ -1,17 +1,6 @@
//! This crate implements diffing utilities. It attempts to provide an abstraction
//! interface over different types of diffing algorithms.
//!
//! # Example
//!
//! ```rust
//! use similar::{text::diff_lines, algorithms::Algorithm};
//! let old = "Hello World!\nMore stuff here.";
//! let new = "Oh well World!\nMore stuff here.";
//! for op in diff_lines(Algorithm::Myers, old, new) {
//! println!("{}", op);
//! }
//! ```
//!
//! # Components
//!
//! The crate is split into two components:

View file

@ -267,39 +267,6 @@ impl<'old, 'new, 'bufs> DiffHook for TextDiffer<'old, 'new, 'bufs> {
}
}
/// Simple utility function to calculate differences between old and new.
pub fn diff_strings<'old, 'new, 'bufs>(
alg: Algorithm,
old: &'bufs [&'old str],
new: &'bufs [&'new str],
) -> Vec<DiffOp<'old, 'new>> {
let mut differ = TextDiffer::new_from_slices(old, new);
differ.set_algorithm(alg);
differ.diff()
}
/// Simple utility function to calculate line differences between old and new.
pub fn diff_lines<'old, 'new>(
alg: Algorithm,
old: &'old str,
new: &'new str,
) -> Vec<DiffOp<'old, 'new>> {
let mut differ = TextDiffer::new_from_lines(old, new);
differ.set_algorithm(alg);
differ.diff()
}
/// Simple utility function to calculate word differences between old and new.
pub fn diff_words<'old, 'new>(
alg: Algorithm,
old: &'old str,
new: &'new str,
) -> Vec<DiffOp<'old, 'new>> {
let mut differ = TextDiffer::new_from_words(old, new);
differ.set_algorithm(alg);
differ.diff()
}
/// Given a string splits it into lines.
///
/// This operation will preserve the newline separation character at the end.
@ -390,7 +357,8 @@ fn test_split_words() {
#[test]
fn test_line_diff() {
insta::assert_debug_snapshot!(diff_lines(Algorithm::Myers, "foo\nbar\nbaz", "foo\nblah\nbaz"), @r###"
let differ = TextDiffer::new_from_lines("foo\nbar\nbaz", "foo\nblah\nbaz");
insta::assert_debug_snapshot!(differ.diff(), @r###"
[
Equal {
old_index: 0,