feat: rename similar -> likewise

This commit is contained in:
Barrett Ruth 2025-09-11 13:31:09 -05:00
parent a169e29954
commit 7e86fb2e55
44 changed files with 64 additions and 391 deletions

View file

@ -1,7 +1,8 @@
[package]
name = "similar"
name = "likewise"
version = "2.7.0"
authors = [
"Barrett Ruth <br.barrettruth@gmail.com>",
"Armin Ronacher <armin.ronacher@active-4.com>",
"Pierre-Étienne Meunier <pe@pijul.org>",
"Brandon Williams <bwilliams.eng@gmail.com>",
@ -9,8 +10,8 @@ authors = [
edition = "2018"
rust-version = "1.60"
license = "Apache-2.0"
description = "A diff library for Rust"
repository = "https://github.com/mitsuhiko/similar"
description = "A diff library for Rust (fork of similar)"
repository = "https://github.com/barrett-ruth/likewise"
keywords = ["diff", "difference", "patience", "compare", "changes"]
readme = "README.md"
exclude = ["assets/*"]

View file

@ -1,11 +1,13 @@
# Similar: A Diffing Library
# Likewise: A Diffing Library
[![Crates.io](https://img.shields.io/crates/d/similar.svg)](https://crates.io/crates/similar)
[![License](https://img.shields.io/github/license/mitsuhiko/similar)](https://github.com/mitsuhiko/similar/blob/main/LICENSE)
> This crate is a fork of [similar](https://github.com/mitsuhiko/similar) library, which, as of 11/9/25, is rather inactive.
[![Crates.io](https://img.shields.io/crates/d/likewise.svg)](https://crates.io/crates/likewise)
[![License](https://img.shields.io/github/license/frozen/likewise)](https://github.com/frozen/likewise/blob/main/LICENSE)
[![rustc 1.60.0](https://img.shields.io/badge/rust-1.60%2B-orange.svg)](https://img.shields.io/badge/rust-1.60%2B-orange.svg)
[![Documentation](https://docs.rs/similar/badge.svg)](https://docs.rs/similar)
[![Documentation](https://docs.rs/likewise/badge.svg)](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
[pijul](https://pijul.org/) implementation of the Patience algorithm and
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).
```rust
use similar::{ChangeTag, TextDiff};
use likewise::{ChangeTag, TextDiff};
fn main() {
let diff = TextDiff::from_lines(
@ -48,12 +50,13 @@ fn main() {
## Related Projects
* [similar](https://github.com/mitsuhiko/similar)
* [insta](https://insta.rs) snapshot testing library
* [similar-asserts](https://github.com/mitsuhiko/similar-asserts) assertion library
## License and Links
* [Documentation](https://docs.rs/similar/)
* [Issue Tracker](https://github.com/mitsuhiko/similar/issues)
* [Examples](https://github.com/mitsuhiko/similar/tree/main/examples)
* License: [Apache-2.0](https://github.com/mitsuhiko/similar/blob/main/LICENSE)
* [Documentation](https://docs.rs/likewise/)
* [Issue Tracker](https://github.com/barrett-ruth/likewise/issues)
* [Examples](https://github.com/barrett-ruth/likewise/tree/main/examples)
* License: [Apache-2.0](https://github.com/barrett-ruth/likewise/blob/main/LICENSE)

View file

@ -1,4 +1,4 @@
use similar::get_close_matches;
use likewise::get_close_matches;
fn main() {
let words = vec![

View file

@ -1,4 +1,4 @@
use similar::TextDiff;
use likewise::TextDiff;
fn main() {
let x = "abc".repeat(2000);

View file

@ -1,4 +1,4 @@
use similar::{capture_diff_slices, Algorithm};
use likewise::{capture_diff_slices, Algorithm};
fn main() {
let old = vec![1, 2, 3];

View file

@ -1,5 +1,5 @@
use similar::utils::diff_chars;
use similar::Algorithm;
use likewise::utils::diff_chars;
use likewise::Algorithm;
fn main() {
let old = "1234567890abcdef".to_string();

View file

@ -1,4 +1,4 @@
use similar::{Algorithm, TextDiff};
use likewise::{Algorithm, TextDiff};
const OLD: &str = r#"
[

View file

@ -1,4 +1,4 @@
use similar::TextDiff;
use likewise::TextDiff;
fn main() {
let diff = TextDiff::from_lines(

View file

@ -3,7 +3,7 @@ use std::fs::read;
use std::process::exit;
use console::{style, Style};
use similar::{ChangeTag, TextDiff};
use likewise::{ChangeTag, TextDiff};
struct Line(Option<usize>);

View file

@ -1,5 +1,5 @@
use console::Style;
use similar::{ChangeTag, TextDiff};
use likewise::{ChangeTag, TextDiff};
fn main() {
let diff = TextDiff::from_lines(

View file

@ -2,7 +2,7 @@ use std::fs::read;
use std::io;
use std::process::exit;
use similar::TextDiff;
use likewise::TextDiff;
fn main() {
let args: Vec<_> = std::env::args_os().collect();

View file

@ -21,7 +21,7 @@
//! between two sequences and capture the ops into a vector.
//!
//! ```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 b = vec![1, 2, 3, 4, 7];

View file

@ -1,6 +1,5 @@
---
source: src/algorithms/lcs.rs
assertion_line: 235
expression: d.ops()
---
[

View file

@ -166,8 +166,8 @@ impl<Int> Index<usize> for OffsetLookup<Int> {
/// you first pass it via [`IdentifyDistinct`]:
///
/// ```rust
/// use similar::capture_diff;
/// use similar::algorithms::{Algorithm, IdentifyDistinct};
/// use likewise::capture_diff;
/// use likewise::algorithms::{Algorithm, IdentifyDistinct};
///
/// let old = &["foo", "bar", "baz"][..];
/// let new = &["foo", "blah", "baz"][..];

View file

@ -21,7 +21,7 @@
//! diff an indexable object or slice and return a vector of [`DiffOp`] objects.
//!
//! ```rust
//! use similar::{Algorithm, capture_diff_slices};
//! use likewise::{Algorithm, capture_diff_slices};
//!
//! let a = vec![1, 2, 3, 4, 5];
//! let b = vec![1, 2, 3, 4, 7];
@ -30,14 +30,14 @@
//!
//! # 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
//! uses the underlying diff algorithms to expose a convenient API to work with
//! texts:
//!
//! ```rust
//! # #[cfg(feature = "text")] {
//! use similar::{ChangeTag, TextDiff};
//! use likewise::{ChangeTag, TextDiff};
//!
//! let diff = TextDiff::from_lines(
//! "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
//! 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
//! instructed to check if there are missing newlines encountered
//! ([`TextDiff::newline_terminated`] returns true).
@ -122,7 +122,7 @@
//! when performing a text diff.
//!
//! 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
//! enabled.
//!

View file

@ -22,4 +22,3 @@ expression: "&diff.unified_diff().header(\"a.txt\", \"b.txt\").to_string()"
P
Q
R

View file

@ -1,10 +1,9 @@
---
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
+++ b.txt
@@ -1 +1 @@
-a
+b

View file

@ -8,4 +8,3 @@ expression: "&diff.unified_diff().header(\"a.txt\", \"b.txt\").to_string()"
-a
+b
\ No newline at end of file

View file

@ -93,7 +93,7 @@ impl TextDiffConfig {
/// influence the behavior of unified diff generation.
///
/// ```rust
/// use similar::{TextDiff, ChangeTag};
/// use likewise::{TextDiff, ChangeTag};
///
/// let diff = TextDiff::configure().diff_lines("a\nb\nc", "a\nb\nC");
/// let changes: Vec<_> = diff
@ -131,7 +131,7 @@ impl TextDiffConfig {
/// which lets you remap the diffs back to the original input strings.
///
/// ```rust
/// use similar::{TextDiff, ChangeTag};
/// use likewise::{TextDiff, ChangeTag};
///
/// let diff = TextDiff::configure().diff_words("foo bar baz", "foo BAR baz");
/// let changes: Vec<_> = diff
@ -169,7 +169,7 @@ impl TextDiffConfig {
/// which lets you remap the diffs back to the original input strings.
///
/// ```rust
/// use similar::{TextDiff, ChangeTag};
/// use likewise::{TextDiff, ChangeTag};
///
/// let diff = TextDiff::configure().diff_chars("abcdef", "abcDDf");
/// let changes: Vec<_> = diff
@ -215,7 +215,7 @@ impl TextDiffConfig {
/// which lets you remap the diffs back to the original input strings.
///
/// ```rust
/// use similar::{TextDiff, ChangeTag};
/// use likewise::{TextDiff, ChangeTag};
///
/// let diff = TextDiff::configure().diff_unicode_words("ah(be)ce", "ah(ah)ce");
/// let changes: Vec<_> = diff
@ -256,7 +256,7 @@ impl TextDiffConfig {
/// which lets you remap the diffs back to the original input strings.
///
/// ```rust
/// use similar::{TextDiff, ChangeTag};
/// use likewise::{TextDiff, ChangeTag};
///
/// let diff = TextDiff::configure().diff_graphemes("💩🇦🇹🦠", "💩🇦🇱❄️");
/// let changes: Vec<_> = diff
@ -288,7 +288,7 @@ impl TextDiffConfig {
/// Creates a diff of arbitrary slices.
///
/// ```rust
/// use similar::{TextDiff, ChangeTag};
/// use likewise::{TextDiff, ChangeTag};
///
/// let old = &["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.
///
/// ```rust
/// # use similar::TextDiff;
/// # use likewise::TextDiff;
/// let diff = TextDiff::from_chars("abcd", "bcde");
/// 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.
///
/// ```
/// # use similar::get_close_matches;
/// # use likewise::get_close_matches;
/// let matches = get_close_matches(
/// "appel",
/// &["ape", "apple", "peach", "puppy"][..],

View file

@ -9,4 +9,3 @@ expression: "&diff.unified_diff().context_radius(3).header(\"old\", \"new\").to_
-some stuff here
+some amazing stuff here
some more stuff here

View file

@ -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",
),
],
},
]

View file

@ -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"
]
]
}
]

View file

@ -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"
}
]

View file

@ -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
}
]

View file

@ -284,8 +284,8 @@ impl DiffOp {
/// the diffing algorithm functions.
///
/// ```rust
/// use similar::{ChangeTag, Algorithm};
/// use similar::capture_diff_slices;
/// use likewise::{ChangeTag, Algorithm};
/// use likewise::capture_diff_slices;
/// let old = vec!["foo", "bar", "baz"];
/// let new = vec!["foo", "bar", "blah"];
/// let ops = capture_diff_slices(Algorithm::Myers, &old, &new);
@ -322,8 +322,8 @@ impl DiffOp {
/// [`DiffOp::Replace`] operation is passed.
///
/// ```rust
/// use similar::{ChangeTag, Algorithm};
/// use similar::capture_diff_slices;
/// use likewise::{ChangeTag, Algorithm};
/// use likewise::capture_diff_slices;
/// let old = vec!["foo", "bar", "baz"];
/// let new = vec!["foo", "bar", "blah"];
/// let ops = capture_diff_slices(Algorithm::Myers, &old, &new);

View file

@ -4,7 +4,7 @@
//! is enabled by default:
//!
//! ```rust
//! use similar::TextDiff;
//! use likewise::TextDiff;
//! # let old_text = "";
//! # let new_text = "";
//! let text_diff = TextDiff::from_lines(old_text, new_text);
@ -101,7 +101,7 @@ impl fmt::Display for UnifiedHunkHeader {
/// Unified diff formatter.
///
/// ```rust
/// use similar::TextDiff;
/// use likewise::TextDiff;
/// # let old_text = "";
/// # let new_text = "";
/// let text_diff = TextDiff::from_lines(old_text, new_text);

View file

@ -76,8 +76,8 @@ impl<T: DiffableStr + ?Sized> Index<Range<usize>> for SliceRemapper<'_, T> {
/// but large consequitive ones from the source.
///
/// ```rust
/// use similar::{ChangeTag, TextDiff};
/// use similar::utils::TextDiffRemapper;
/// use likewise::{ChangeTag, TextDiff};
/// use likewise::utils::TextDiffRemapper;
///
/// let old = "yo! foo bar baz";
/// let new = "yo! foo bor baz";
@ -198,8 +198,8 @@ impl<'x, T: DiffableStr + ?Sized> TextDiffRemapper<'x, T> {
/// with the changes.
///
/// ```rust
/// use similar::{Algorithm, ChangeTag};
/// use similar::utils::diff_slices;
/// use likewise::{Algorithm, ChangeTag};
/// use likewise::utils::diff_slices;
///
/// let old = "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.
///
/// ```rust
/// use similar::{Algorithm, ChangeTag};
/// use similar::utils::diff_chars;
/// use likewise::{Algorithm, ChangeTag};
/// use likewise::utils::diff_chars;
///
/// assert_eq!(diff_chars(Algorithm::Myers, "foobarbaz", "fooBARbaz"), vec![
/// (ChangeTag::Equal, "foo"),
@ -259,8 +259,8 @@ pub fn diff_chars<'x, T: DiffableStrRef + ?Sized>(
/// rather than word level slices.
///
/// ```rust
/// use similar::{Algorithm, ChangeTag};
/// use similar::utils::diff_words;
/// use likewise::{Algorithm, ChangeTag};
/// use likewise::utils::diff_words;
///
/// assert_eq!(diff_words(Algorithm::Myers, "foo bar baz", "foo bor baz"), vec![
/// (ChangeTag::Equal, "foo "),
@ -291,8 +291,8 @@ pub fn diff_words<'x, T: DiffableStrRef + ?Sized>(
/// rather than word level slices.
///
/// ```rust
/// use similar::{Algorithm, ChangeTag};
/// use similar::utils::diff_unicode_words;
/// use likewise::{Algorithm, ChangeTag};
/// use likewise::utils::diff_unicode_words;
///
/// 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?";
@ -333,8 +333,8 @@ pub fn diff_unicode_words<'x, T: DiffableStrRef + ?Sized>(
/// rather than grapheme level slices.
///
/// ```rust
/// use similar::{Algorithm, ChangeTag};
/// use similar::utils::diff_graphemes;
/// use likewise::{Algorithm, ChangeTag};
/// use likewise::utils::diff_graphemes;
///
/// let old = "The flag of Austria 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.
///
/// ```rust
/// use similar::{Algorithm, ChangeTag};
/// use similar::utils::diff_lines;
/// use likewise::{Algorithm, ChangeTag};
/// use likewise::utils::diff_lines;
///
/// assert_eq!(diff_lines(Algorithm::Myers, "foo\nbar\nbaz\nblah", "foo\nbar\nbaz\nblurgh"), vec![
/// (ChangeTag::Equal, "foo\n"),