feat: rename similar -> likewise
This commit is contained in:
parent
a169e29954
commit
7e86fb2e55
44 changed files with 64 additions and 391 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
[package]
|
[package]
|
||||||
name = "similar"
|
name = "likewise"
|
||||||
version = "2.7.0"
|
version = "2.7.0"
|
||||||
authors = [
|
authors = [
|
||||||
|
"Barrett Ruth <br.barrettruth@gmail.com>",
|
||||||
"Armin Ronacher <armin.ronacher@active-4.com>",
|
"Armin Ronacher <armin.ronacher@active-4.com>",
|
||||||
"Pierre-Étienne Meunier <pe@pijul.org>",
|
"Pierre-Étienne Meunier <pe@pijul.org>",
|
||||||
"Brandon Williams <bwilliams.eng@gmail.com>",
|
"Brandon Williams <bwilliams.eng@gmail.com>",
|
||||||
|
|
@ -9,8 +10,8 @@ authors = [
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
rust-version = "1.60"
|
rust-version = "1.60"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
description = "A diff library for Rust"
|
description = "A diff library for Rust (fork of similar)"
|
||||||
repository = "https://github.com/mitsuhiko/similar"
|
repository = "https://github.com/barrett-ruth/likewise"
|
||||||
keywords = ["diff", "difference", "patience", "compare", "changes"]
|
keywords = ["diff", "difference", "patience", "compare", "changes"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
exclude = ["assets/*"]
|
exclude = ["assets/*"]
|
||||||
|
|
|
||||||
23
README.md
23
README.md
|
|
@ -1,11 +1,13 @@
|
||||||
# Similar: A Diffing Library
|
# Likewise: A Diffing Library
|
||||||
|
|
||||||
[](https://crates.io/crates/similar)
|
> This crate is a fork of [similar](https://github.com/mitsuhiko/similar) library, which, as of 11/9/25, is rather inactive.
|
||||||
[](https://github.com/mitsuhiko/similar/blob/main/LICENSE)
|
|
||||||
|
[](https://crates.io/crates/likewise)
|
||||||
|
[](https://github.com/frozen/likewise/blob/main/LICENSE)
|
||||||
[](https://img.shields.io/badge/rust-1.60%2B-orange.svg)
|
[](https://img.shields.io/badge/rust-1.60%2B-orange.svg)
|
||||||
[](https://docs.rs/similar)
|
[](https://docs.rs/likewise)
|
||||||
|
|
||||||
Similar is a dependency free crate for Rust that implements different diffing
|
Likewise is a dependency free crate for Rust that implements different diffing
|
||||||
algorithms and high level interfaces for it. It is based on the
|
algorithms and high level interfaces for it. It is based on the
|
||||||
[pijul](https://pijul.org/) implementation of the Patience algorithm and
|
[pijul](https://pijul.org/) implementation of the Patience algorithm and
|
||||||
inherits some ideas from there. It also incorporates the Myers' diff
|
inherits some ideas from there. It also incorporates the Myers' diff
|
||||||
|
|
@ -13,7 +15,7 @@ algorithm which was largely written by Brandon Williams. This library was
|
||||||
built for the [insta snapshot testing library](https://insta.rs).
|
built for the [insta snapshot testing library](https://insta.rs).
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use similar::{ChangeTag, TextDiff};
|
use likewise::{ChangeTag, TextDiff};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let diff = TextDiff::from_lines(
|
let diff = TextDiff::from_lines(
|
||||||
|
|
@ -48,12 +50,13 @@ fn main() {
|
||||||
|
|
||||||
## Related Projects
|
## Related Projects
|
||||||
|
|
||||||
|
* [similar](https://github.com/mitsuhiko/similar)
|
||||||
* [insta](https://insta.rs) snapshot testing library
|
* [insta](https://insta.rs) snapshot testing library
|
||||||
* [similar-asserts](https://github.com/mitsuhiko/similar-asserts) assertion library
|
* [similar-asserts](https://github.com/mitsuhiko/similar-asserts) assertion library
|
||||||
|
|
||||||
## License and Links
|
## License and Links
|
||||||
|
|
||||||
* [Documentation](https://docs.rs/similar/)
|
* [Documentation](https://docs.rs/likewise/)
|
||||||
* [Issue Tracker](https://github.com/mitsuhiko/similar/issues)
|
* [Issue Tracker](https://github.com/barrett-ruth/likewise/issues)
|
||||||
* [Examples](https://github.com/mitsuhiko/similar/tree/main/examples)
|
* [Examples](https://github.com/barrett-ruth/likewise/tree/main/examples)
|
||||||
* License: [Apache-2.0](https://github.com/mitsuhiko/similar/blob/main/LICENSE)
|
* License: [Apache-2.0](https://github.com/barrett-ruth/likewise/blob/main/LICENSE)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use similar::get_close_matches;
|
use likewise::get_close_matches;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let words = vec![
|
let words = vec![
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use similar::TextDiff;
|
use likewise::TextDiff;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = "abc".repeat(2000);
|
let x = "abc".repeat(2000);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use similar::{capture_diff_slices, Algorithm};
|
use likewise::{capture_diff_slices, Algorithm};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let old = vec![1, 2, 3];
|
let old = vec![1, 2, 3];
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use similar::utils::diff_chars;
|
use likewise::utils::diff_chars;
|
||||||
use similar::Algorithm;
|
use likewise::Algorithm;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let old = "1234567890abcdef".to_string();
|
let old = "1234567890abcdef".to_string();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use similar::{Algorithm, TextDiff};
|
use likewise::{Algorithm, TextDiff};
|
||||||
|
|
||||||
const OLD: &str = r#"
|
const OLD: &str = r#"
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use similar::TextDiff;
|
use likewise::TextDiff;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let diff = TextDiff::from_lines(
|
let diff = TextDiff::from_lines(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::fs::read;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
use console::{style, Style};
|
use console::{style, Style};
|
||||||
use similar::{ChangeTag, TextDiff};
|
use likewise::{ChangeTag, TextDiff};
|
||||||
|
|
||||||
struct Line(Option<usize>);
|
struct Line(Option<usize>);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use console::Style;
|
use console::Style;
|
||||||
use similar::{ChangeTag, TextDiff};
|
use likewise::{ChangeTag, TextDiff};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let diff = TextDiff::from_lines(
|
let diff = TextDiff::from_lines(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::fs::read;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
use similar::TextDiff;
|
use likewise::TextDiff;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<_> = std::env::args_os().collect();
|
let args: Vec<_> = std::env::args_os().collect();
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
//! between two sequences and capture the ops into a vector.
|
//! between two sequences and capture the ops into a vector.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use similar::algorithms::{Algorithm, Replace, Capture, diff_slices};
|
//! use likewise::algorithms::{Algorithm, Replace, Capture, diff_slices};
|
||||||
//!
|
//!
|
||||||
//! let a = vec![1, 2, 3, 4, 5];
|
//! let a = vec![1, 2, 3, 4, 5];
|
||||||
//! let b = vec![1, 2, 3, 4, 7];
|
//! let b = vec![1, 2, 3, 4, 7];
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/algorithms/lcs.rs
|
source: src/algorithms/lcs.rs
|
||||||
assertion_line: 235
|
|
||||||
expression: d.ops()
|
expression: d.ops()
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
|
|
@ -166,8 +166,8 @@ impl<Int> Index<usize> for OffsetLookup<Int> {
|
||||||
/// you first pass it via [`IdentifyDistinct`]:
|
/// you first pass it via [`IdentifyDistinct`]:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::capture_diff;
|
/// use likewise::capture_diff;
|
||||||
/// use similar::algorithms::{Algorithm, IdentifyDistinct};
|
/// use likewise::algorithms::{Algorithm, IdentifyDistinct};
|
||||||
///
|
///
|
||||||
/// let old = &["foo", "bar", "baz"][..];
|
/// let old = &["foo", "bar", "baz"][..];
|
||||||
/// let new = &["foo", "blah", "baz"][..];
|
/// let new = &["foo", "blah", "baz"][..];
|
||||||
|
|
|
||||||
10
src/lib.rs
10
src/lib.rs
|
|
@ -21,7 +21,7 @@
|
||||||
//! diff an indexable object or slice and return a vector of [`DiffOp`] objects.
|
//! diff an indexable object or slice and return a vector of [`DiffOp`] objects.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use similar::{Algorithm, capture_diff_slices};
|
//! use likewise::{Algorithm, capture_diff_slices};
|
||||||
//!
|
//!
|
||||||
//! let a = vec![1, 2, 3, 4, 5];
|
//! let a = vec![1, 2, 3, 4, 5];
|
||||||
//! let b = vec![1, 2, 3, 4, 7];
|
//! let b = vec![1, 2, 3, 4, 7];
|
||||||
|
|
@ -30,14 +30,14 @@
|
||||||
//!
|
//!
|
||||||
//! # Text Diffing
|
//! # Text Diffing
|
||||||
//!
|
//!
|
||||||
//! Similar provides helpful utilities for text (and more specifically line) diff
|
//! Likewise provides helpful utilities for text (and more specifically line) diff
|
||||||
//! operations. The main type you want to work with is [`TextDiff`] which
|
//! operations. The main type you want to work with is [`TextDiff`] which
|
||||||
//! uses the underlying diff algorithms to expose a convenient API to work with
|
//! uses the underlying diff algorithms to expose a convenient API to work with
|
||||||
//! texts:
|
//! texts:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! # #[cfg(feature = "text")] {
|
//! # #[cfg(feature = "text")] {
|
||||||
//! use similar::{ChangeTag, TextDiff};
|
//! use likewise::{ChangeTag, TextDiff};
|
||||||
//!
|
//!
|
||||||
//! let diff = TextDiff::from_lines(
|
//! let diff = TextDiff::from_lines(
|
||||||
//! "Hello World\nThis is the second line.\nThis is the third.",
|
//! "Hello World\nThis is the second line.\nThis is the third.",
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
//! As a result there is a difference between `foo\n` and `foo` as far as diffs
|
//! As a result there is a difference between `foo\n` and `foo` as far as diffs
|
||||||
//! are concerned.
|
//! are concerned.
|
||||||
//!
|
//!
|
||||||
//! In similar this is handled on the [`Change`] or [`InlineChange`] level. If
|
//! In likewise this is handled on the [`Change`] or [`InlineChange`] level. If
|
||||||
//! a diff was created via [`TextDiff::from_lines`] the text diffing system is
|
//! a diff was created via [`TextDiff::from_lines`] the text diffing system is
|
||||||
//! instructed to check if there are missing newlines encountered
|
//! instructed to check if there are missing newlines encountered
|
||||||
//! ([`TextDiff::newline_terminated`] returns true).
|
//! ([`TextDiff::newline_terminated`] returns true).
|
||||||
|
|
@ -122,7 +122,7 @@
|
||||||
//! when performing a text diff.
|
//! when performing a text diff.
|
||||||
//!
|
//!
|
||||||
//! Note that on wasm targets calling [`Instant::now`] will result in a panic
|
//! Note that on wasm targets calling [`Instant::now`] will result in a panic
|
||||||
//! unless you enable the `wasm32_web_time` feataure. By default similar will
|
//! unless you enable the `wasm32_web_time` feataure. By default likewise will
|
||||||
//! silently disable the deadline checks internally unless that feature is
|
//! silently disable the deadline checks internally unless that feature is
|
||||||
//! enabled.
|
//! enabled.
|
||||||
//!
|
//!
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,3 @@ expression: "&diff.unified_diff().header(\"a.txt\", \"b.txt\").to_string()"
|
||||||
P
|
P
|
||||||
Q
|
Q
|
||||||
R
|
R
|
||||||
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
---
|
---
|
||||||
source: src/udiff.rs
|
source: src/udiff.rs
|
||||||
expression: "&diff.unified_diff().missing_newline_hint(false).header(\"a.txt\",\n \"b.txt\").to_string()"
|
expression: "&diff.unified_diff().missing_newline_hint(false).header(\"a.txt\",\n\"b.txt\").to_string()"
|
||||||
---
|
---
|
||||||
--- a.txt
|
--- a.txt
|
||||||
+++ b.txt
|
+++ b.txt
|
||||||
@@ -1 +1 @@
|
@@ -1 +1 @@
|
||||||
-a
|
-a
|
||||||
+b
|
+b
|
||||||
|
|
||||||
|
|
@ -8,4 +8,3 @@ expression: "&diff.unified_diff().header(\"a.txt\", \"b.txt\").to_string()"
|
||||||
-a
|
-a
|
||||||
+b
|
+b
|
||||||
\ No newline at end of file
|
\ No newline at end of file
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ impl TextDiffConfig {
|
||||||
/// influence the behavior of unified diff generation.
|
/// influence the behavior of unified diff generation.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{TextDiff, ChangeTag};
|
/// use likewise::{TextDiff, ChangeTag};
|
||||||
///
|
///
|
||||||
/// let diff = TextDiff::configure().diff_lines("a\nb\nc", "a\nb\nC");
|
/// let diff = TextDiff::configure().diff_lines("a\nb\nc", "a\nb\nC");
|
||||||
/// let changes: Vec<_> = diff
|
/// let changes: Vec<_> = diff
|
||||||
|
|
@ -131,7 +131,7 @@ impl TextDiffConfig {
|
||||||
/// which lets you remap the diffs back to the original input strings.
|
/// which lets you remap the diffs back to the original input strings.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{TextDiff, ChangeTag};
|
/// use likewise::{TextDiff, ChangeTag};
|
||||||
///
|
///
|
||||||
/// let diff = TextDiff::configure().diff_words("foo bar baz", "foo BAR baz");
|
/// let diff = TextDiff::configure().diff_words("foo bar baz", "foo BAR baz");
|
||||||
/// let changes: Vec<_> = diff
|
/// let changes: Vec<_> = diff
|
||||||
|
|
@ -169,7 +169,7 @@ impl TextDiffConfig {
|
||||||
/// which lets you remap the diffs back to the original input strings.
|
/// which lets you remap the diffs back to the original input strings.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{TextDiff, ChangeTag};
|
/// use likewise::{TextDiff, ChangeTag};
|
||||||
///
|
///
|
||||||
/// let diff = TextDiff::configure().diff_chars("abcdef", "abcDDf");
|
/// let diff = TextDiff::configure().diff_chars("abcdef", "abcDDf");
|
||||||
/// let changes: Vec<_> = diff
|
/// let changes: Vec<_> = diff
|
||||||
|
|
@ -215,7 +215,7 @@ impl TextDiffConfig {
|
||||||
/// which lets you remap the diffs back to the original input strings.
|
/// which lets you remap the diffs back to the original input strings.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{TextDiff, ChangeTag};
|
/// use likewise::{TextDiff, ChangeTag};
|
||||||
///
|
///
|
||||||
/// let diff = TextDiff::configure().diff_unicode_words("ah(be)ce", "ah(ah)ce");
|
/// let diff = TextDiff::configure().diff_unicode_words("ah(be)ce", "ah(ah)ce");
|
||||||
/// let changes: Vec<_> = diff
|
/// let changes: Vec<_> = diff
|
||||||
|
|
@ -256,7 +256,7 @@ impl TextDiffConfig {
|
||||||
/// which lets you remap the diffs back to the original input strings.
|
/// which lets you remap the diffs back to the original input strings.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{TextDiff, ChangeTag};
|
/// use likewise::{TextDiff, ChangeTag};
|
||||||
///
|
///
|
||||||
/// let diff = TextDiff::configure().diff_graphemes("💩🇦🇹🦠", "💩🇦🇱❄️");
|
/// let diff = TextDiff::configure().diff_graphemes("💩🇦🇹🦠", "💩🇦🇱❄️");
|
||||||
/// let changes: Vec<_> = diff
|
/// let changes: Vec<_> = diff
|
||||||
|
|
@ -288,7 +288,7 @@ impl TextDiffConfig {
|
||||||
/// Creates a diff of arbitrary slices.
|
/// Creates a diff of arbitrary slices.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{TextDiff, ChangeTag};
|
/// use likewise::{TextDiff, ChangeTag};
|
||||||
///
|
///
|
||||||
/// let old = &["foo", "bar", "baz"];
|
/// let old = &["foo", "bar", "baz"];
|
||||||
/// let new = &["foo", "BAR", "baz"];
|
/// let new = &["foo", "BAR", "baz"];
|
||||||
|
|
@ -469,7 +469,7 @@ impl<'old, 'new, 'bufs, T: DiffableStr + ?Sized + 'old + 'new> TextDiff<'old, 'n
|
||||||
/// ratio of `0.0` would indicate completely distinct sequences.
|
/// ratio of `0.0` would indicate completely distinct sequences.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use similar::TextDiff;
|
/// # use likewise::TextDiff;
|
||||||
/// let diff = TextDiff::from_chars("abcd", "bcde");
|
/// let diff = TextDiff::from_chars("abcd", "bcde");
|
||||||
/// assert_eq!(diff.ratio(), 0.75);
|
/// assert_eq!(diff.ratio(), 0.75);
|
||||||
/// ```
|
/// ```
|
||||||
|
|
@ -575,7 +575,7 @@ impl<'old, 'new, 'bufs, T: DiffableStr + ?Sized + 'old + 'new> TextDiff<'old, 'n
|
||||||
/// to be considered similar. See [`TextDiff::ratio`] for more information.
|
/// to be considered similar. See [`TextDiff::ratio`] for more information.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use similar::get_close_matches;
|
/// # use likewise::get_close_matches;
|
||||||
/// let matches = get_close_matches(
|
/// let matches = get_close_matches(
|
||||||
/// "appel",
|
/// "appel",
|
||||||
/// &["ape", "apple", "peach", "puppy"][..],
|
/// &["ape", "apple", "peach", "puppy"][..],
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,3 @@ expression: "&diff.unified_diff().context_radius(3).header(\"old\", \"new\").to_
|
||||||
-some stuff here
|
-some stuff here
|
||||||
+some amazing stuff here
|
+some amazing stuff here
|
||||||
some more stuff here
|
some more stuff here
|
||||||
|
|
||||||
|
|
@ -1,126 +0,0 @@
|
||||||
---
|
|
||||||
source: src/text/inline.rs
|
|
||||||
expression: "&changes"
|
|
||||||
---
|
|
||||||
[
|
|
||||||
InlineChange {
|
|
||||||
tag: Insert,
|
|
||||||
old_index: None,
|
|
||||||
new_index: Some(
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
values: [
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"Stuff\n",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
InlineChange {
|
|
||||||
tag: Equal,
|
|
||||||
old_index: Some(
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
new_index: Some(
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
values: [
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"Hello World\n",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
InlineChange {
|
|
||||||
tag: Delete,
|
|
||||||
old_index: Some(
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
new_index: None,
|
|
||||||
values: [
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"some ",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"stuff here\n",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
InlineChange {
|
|
||||||
tag: Insert,
|
|
||||||
old_index: None,
|
|
||||||
new_index: Some(
|
|
||||||
2,
|
|
||||||
),
|
|
||||||
values: [
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"some ",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
true,
|
|
||||||
"amazing ",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"stuff here\n",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
InlineChange {
|
|
||||||
tag: Equal,
|
|
||||||
old_index: Some(
|
|
||||||
2,
|
|
||||||
),
|
|
||||||
new_index: Some(
|
|
||||||
3,
|
|
||||||
),
|
|
||||||
values: [
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"some more stuff here\n",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
InlineChange {
|
|
||||||
tag: Delete,
|
|
||||||
old_index: Some(
|
|
||||||
3,
|
|
||||||
),
|
|
||||||
new_index: None,
|
|
||||||
values: [
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"\n",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
InlineChange {
|
|
||||||
tag: Delete,
|
|
||||||
old_index: Some(
|
|
||||||
4,
|
|
||||||
),
|
|
||||||
new_index: None,
|
|
||||||
values: [
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"Aha stuff here\n",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
InlineChange {
|
|
||||||
tag: Delete,
|
|
||||||
old_index: Some(
|
|
||||||
5,
|
|
||||||
),
|
|
||||||
new_index: None,
|
|
||||||
values: [
|
|
||||||
(
|
|
||||||
false,
|
|
||||||
"and more stuff",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
---
|
|
||||||
source: src/text/inline.rs
|
|
||||||
expression: "&json"
|
|
||||||
|
|
||||||
---
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"tag": "insert",
|
|
||||||
"old_index": null,
|
|
||||||
"new_index": 0,
|
|
||||||
"values": [
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"Stuff\n"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "equal",
|
|
||||||
"old_index": 0,
|
|
||||||
"new_index": 1,
|
|
||||||
"values": [
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"Hello World\n"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "delete",
|
|
||||||
"old_index": 1,
|
|
||||||
"new_index": null,
|
|
||||||
"values": [
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"some "
|
|
||||||
],
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"stuff here\n"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "insert",
|
|
||||||
"old_index": null,
|
|
||||||
"new_index": 2,
|
|
||||||
"values": [
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"some "
|
|
||||||
],
|
|
||||||
[
|
|
||||||
true,
|
|
||||||
"amazing "
|
|
||||||
],
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"stuff here\n"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "equal",
|
|
||||||
"old_index": 2,
|
|
||||||
"new_index": 3,
|
|
||||||
"values": [
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"some more stuff here\n"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "delete",
|
|
||||||
"old_index": 3,
|
|
||||||
"new_index": null,
|
|
||||||
"values": [
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"\n"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "delete",
|
|
||||||
"old_index": 4,
|
|
||||||
"new_index": null,
|
|
||||||
"values": [
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"Aha stuff here\n"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "delete",
|
|
||||||
"old_index": 5,
|
|
||||||
"new_index": null,
|
|
||||||
"values": [
|
|
||||||
[
|
|
||||||
false,
|
|
||||||
"and more stuff"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
---
|
|
||||||
source: src/text/mod.rs
|
|
||||||
expression: "&json"
|
|
||||||
|
|
||||||
---
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"tag": "insert",
|
|
||||||
"old_index": null,
|
|
||||||
"new_index": 0,
|
|
||||||
"value": "Stuff\n"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "equal",
|
|
||||||
"old_index": 0,
|
|
||||||
"new_index": 1,
|
|
||||||
"value": "Hello World\n"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "delete",
|
|
||||||
"old_index": 1,
|
|
||||||
"new_index": null,
|
|
||||||
"value": "some stuff here\n"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "insert",
|
|
||||||
"old_index": null,
|
|
||||||
"new_index": 2,
|
|
||||||
"value": "some amazing stuff here\n"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "equal",
|
|
||||||
"old_index": 2,
|
|
||||||
"new_index": 3,
|
|
||||||
"value": "some more stuff here\n"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "delete",
|
|
||||||
"old_index": 3,
|
|
||||||
"new_index": null,
|
|
||||||
"value": "\n"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "delete",
|
|
||||||
"old_index": 4,
|
|
||||||
"new_index": null,
|
|
||||||
"value": "Aha stuff here\n"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "delete",
|
|
||||||
"old_index": 5,
|
|
||||||
"new_index": null,
|
|
||||||
"value": "and more stuff"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
---
|
|
||||||
source: src/text/mod.rs
|
|
||||||
expression: "&json"
|
|
||||||
|
|
||||||
---
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"op": "insert",
|
|
||||||
"old_index": 0,
|
|
||||||
"new_index": 0,
|
|
||||||
"new_len": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"op": "equal",
|
|
||||||
"old_index": 0,
|
|
||||||
"new_index": 1,
|
|
||||||
"len": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"op": "replace",
|
|
||||||
"old_index": 1,
|
|
||||||
"old_len": 1,
|
|
||||||
"new_index": 2,
|
|
||||||
"new_len": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"op": "equal",
|
|
||||||
"old_index": 2,
|
|
||||||
"new_index": 3,
|
|
||||||
"len": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"op": "delete",
|
|
||||||
"old_index": 3,
|
|
||||||
"old_len": 3,
|
|
||||||
"new_index": 4
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -284,8 +284,8 @@ impl DiffOp {
|
||||||
/// the diffing algorithm functions.
|
/// the diffing algorithm functions.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{ChangeTag, Algorithm};
|
/// use likewise::{ChangeTag, Algorithm};
|
||||||
/// use similar::capture_diff_slices;
|
/// use likewise::capture_diff_slices;
|
||||||
/// let old = vec!["foo", "bar", "baz"];
|
/// let old = vec!["foo", "bar", "baz"];
|
||||||
/// let new = vec!["foo", "bar", "blah"];
|
/// let new = vec!["foo", "bar", "blah"];
|
||||||
/// let ops = capture_diff_slices(Algorithm::Myers, &old, &new);
|
/// let ops = capture_diff_slices(Algorithm::Myers, &old, &new);
|
||||||
|
|
@ -322,8 +322,8 @@ impl DiffOp {
|
||||||
/// [`DiffOp::Replace`] operation is passed.
|
/// [`DiffOp::Replace`] operation is passed.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{ChangeTag, Algorithm};
|
/// use likewise::{ChangeTag, Algorithm};
|
||||||
/// use similar::capture_diff_slices;
|
/// use likewise::capture_diff_slices;
|
||||||
/// let old = vec!["foo", "bar", "baz"];
|
/// let old = vec!["foo", "bar", "baz"];
|
||||||
/// let new = vec!["foo", "bar", "blah"];
|
/// let new = vec!["foo", "bar", "blah"];
|
||||||
/// let ops = capture_diff_slices(Algorithm::Myers, &old, &new);
|
/// let ops = capture_diff_slices(Algorithm::Myers, &old, &new);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
//! is enabled by default:
|
//! is enabled by default:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use similar::TextDiff;
|
//! use likewise::TextDiff;
|
||||||
//! # let old_text = "";
|
//! # let old_text = "";
|
||||||
//! # let new_text = "";
|
//! # let new_text = "";
|
||||||
//! let text_diff = TextDiff::from_lines(old_text, new_text);
|
//! let text_diff = TextDiff::from_lines(old_text, new_text);
|
||||||
|
|
@ -101,7 +101,7 @@ impl fmt::Display for UnifiedHunkHeader {
|
||||||
/// Unified diff formatter.
|
/// Unified diff formatter.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::TextDiff;
|
/// use likewise::TextDiff;
|
||||||
/// # let old_text = "";
|
/// # let old_text = "";
|
||||||
/// # let new_text = "";
|
/// # let new_text = "";
|
||||||
/// let text_diff = TextDiff::from_lines(old_text, new_text);
|
/// let text_diff = TextDiff::from_lines(old_text, new_text);
|
||||||
|
|
|
||||||
28
src/utils.rs
28
src/utils.rs
|
|
@ -76,8 +76,8 @@ impl<T: DiffableStr + ?Sized> Index<Range<usize>> for SliceRemapper<'_, T> {
|
||||||
/// but large consequitive ones from the source.
|
/// but large consequitive ones from the source.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{ChangeTag, TextDiff};
|
/// use likewise::{ChangeTag, TextDiff};
|
||||||
/// use similar::utils::TextDiffRemapper;
|
/// use likewise::utils::TextDiffRemapper;
|
||||||
///
|
///
|
||||||
/// let old = "yo! foo bar baz";
|
/// let old = "yo! foo bar baz";
|
||||||
/// let new = "yo! foo bor baz";
|
/// let new = "yo! foo bor baz";
|
||||||
|
|
@ -198,8 +198,8 @@ impl<'x, T: DiffableStr + ?Sized> TextDiffRemapper<'x, T> {
|
||||||
/// with the changes.
|
/// with the changes.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{Algorithm, ChangeTag};
|
/// use likewise::{Algorithm, ChangeTag};
|
||||||
/// use similar::utils::diff_slices;
|
/// use likewise::utils::diff_slices;
|
||||||
///
|
///
|
||||||
/// let old = "foo\nbar\nbaz".lines().collect::<Vec<_>>();
|
/// let old = "foo\nbar\nbaz".lines().collect::<Vec<_>>();
|
||||||
/// let new = "foo\nbar\nBAZ".lines().collect::<Vec<_>>();
|
/// let new = "foo\nbar\nBAZ".lines().collect::<Vec<_>>();
|
||||||
|
|
@ -227,8 +227,8 @@ pub fn diff_slices<'x, T: PartialEq + Hash + Ord>(
|
||||||
/// rather than character level slices.
|
/// rather than character level slices.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{Algorithm, ChangeTag};
|
/// use likewise::{Algorithm, ChangeTag};
|
||||||
/// use similar::utils::diff_chars;
|
/// use likewise::utils::diff_chars;
|
||||||
///
|
///
|
||||||
/// assert_eq!(diff_chars(Algorithm::Myers, "foobarbaz", "fooBARbaz"), vec![
|
/// assert_eq!(diff_chars(Algorithm::Myers, "foobarbaz", "fooBARbaz"), vec![
|
||||||
/// (ChangeTag::Equal, "foo"),
|
/// (ChangeTag::Equal, "foo"),
|
||||||
|
|
@ -259,8 +259,8 @@ pub fn diff_chars<'x, T: DiffableStrRef + ?Sized>(
|
||||||
/// rather than word level slices.
|
/// rather than word level slices.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{Algorithm, ChangeTag};
|
/// use likewise::{Algorithm, ChangeTag};
|
||||||
/// use similar::utils::diff_words;
|
/// use likewise::utils::diff_words;
|
||||||
///
|
///
|
||||||
/// assert_eq!(diff_words(Algorithm::Myers, "foo bar baz", "foo bor baz"), vec![
|
/// assert_eq!(diff_words(Algorithm::Myers, "foo bar baz", "foo bor baz"), vec![
|
||||||
/// (ChangeTag::Equal, "foo "),
|
/// (ChangeTag::Equal, "foo "),
|
||||||
|
|
@ -291,8 +291,8 @@ pub fn diff_words<'x, T: DiffableStrRef + ?Sized>(
|
||||||
/// rather than word level slices.
|
/// rather than word level slices.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{Algorithm, ChangeTag};
|
/// use likewise::{Algorithm, ChangeTag};
|
||||||
/// use similar::utils::diff_unicode_words;
|
/// use likewise::utils::diff_unicode_words;
|
||||||
///
|
///
|
||||||
/// let old = "The quick (\"brown\") fox can't jump 32.3 feet, right?";
|
/// let old = "The quick (\"brown\") fox can't jump 32.3 feet, right?";
|
||||||
/// let new = "The quick (\"brown\") fox can't jump 9.84 meters, right?";
|
/// let new = "The quick (\"brown\") fox can't jump 9.84 meters, right?";
|
||||||
|
|
@ -333,8 +333,8 @@ pub fn diff_unicode_words<'x, T: DiffableStrRef + ?Sized>(
|
||||||
/// rather than grapheme level slices.
|
/// rather than grapheme level slices.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{Algorithm, ChangeTag};
|
/// use likewise::{Algorithm, ChangeTag};
|
||||||
/// use similar::utils::diff_graphemes;
|
/// use likewise::utils::diff_graphemes;
|
||||||
///
|
///
|
||||||
/// let old = "The flag of Austria is 🇦🇹";
|
/// let old = "The flag of Austria is 🇦🇹";
|
||||||
/// let new = "The flag of Albania is 🇦🇱";
|
/// let new = "The flag of Albania is 🇦🇱";
|
||||||
|
|
@ -374,8 +374,8 @@ pub fn diff_graphemes<'x, T: DiffableStrRef + ?Sized>(
|
||||||
/// change tag for each line.
|
/// change tag for each line.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use similar::{Algorithm, ChangeTag};
|
/// use likewise::{Algorithm, ChangeTag};
|
||||||
/// use similar::utils::diff_lines;
|
/// use likewise::utils::diff_lines;
|
||||||
///
|
///
|
||||||
/// assert_eq!(diff_lines(Algorithm::Myers, "foo\nbar\nbaz\nblah", "foo\nbar\nbaz\nblurgh"), vec![
|
/// assert_eq!(diff_lines(Algorithm::Myers, "foo\nbar\nbaz\nblah", "foo\nbar\nbaz\nblurgh"), vec![
|
||||||
/// (ChangeTag::Equal, "foo\n"),
|
/// (ChangeTag::Equal, "foo\n"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue