Merge pull request #3 from barrett-ruth/feat/rename

rename similar to likewise
This commit is contained in:
Barrett Ruth 2025-09-11 21:56:00 +02:00 committed by GitHub
commit 26e9d9c70f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 252 additions and 284 deletions

View file

@ -16,14 +16,14 @@ jobs:
run: make test
build-stable:
name: Build on 1.60.0
name: Build on 1.66.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.60.0
toolchain: 1.66.0
- name: Use Cargo.lock.msrv
run: cp Cargo.lock.msrv Cargo.lock
- name: Test

View file

@ -1,132 +0,0 @@
# Changelog
All notable changes to similar are documented here.
## 2.7.0
* Add optional support for `web-time` to support web WASM targets. #73
* Crate will no longer panic wheh deadlines are used in WASM. At worst
deadlines are silently ignored. To enforce deadlines enable the
`wasm32_web_time` feature. #74
## 2.6.0
* Bump bstr dependency to 1.5. #69
## 2.5.0
* Added support for `TextDiff::iter_inline_changes_deadline`. #61
* Raise MSRV to 1.60. #62
* Bump bstr dependency to 1.0. #62
## 2.4.0
* Fixed a bug where the LCS diff algorithm didn't always call `D::finish`. (#58)
* Fixed a bug in LCS that caused a panic if the common prefix and the
common suffix overlapped. (#59)
## 2.3.0
* Added support for `Change::value_ref` and `Change::value_mut`.
## 2.2.1
* Fixed a panic in LCS diffs on matching input. (#43)
## 2.2.0
* Fixed a panic in text diff generation. (#37)
## 2.1.0
* Removed deprecated alternative slice diffing functions.
* Added `serde` feature to allow serialization with serde.
## 2.0.0
* Change the `Change` type and associated methods to work on any `T: Clone` instead
of `&T`. This makes the `iter_changes` method also work on slices of integers
or other values.
## 1.3.0
* Performance improvements for the LCS algorithm.
* Small performance improvements by adding an early opt-out for and inline highlighting.
* Added `IdentifyDistinct` to convert sequences to ints.
* Small performance improvements for larger text diffs by using `IdentifyDistinct`
automatically above a threshold.
* Added deadlines to all diffing algorithms to bail early.
* Deprecated slice diffing methods in the individual algorithm modules.
* Use a default timeout for the inline highlighting feature.
* Added a compacting step to clean up diffs. This results in nicer looking diffs and
fewer edits. This is happening automatically for captured diffs and is exposed
through the `Capture` type.
* Fix incorrect ranges in unified diff output.
## 1.2.2
* Added support for Rust 1.41.0 for better compatibility.
## 1.2.1
* Added support for Rust 1.43.0 for better compatibility.
## 1.2.0
* Make the unicode feature optional for inline diffing.
* Added HuntMcIlroy LCS algorithm (`lcs`).
* Changed the implementation of Mayer's diff. This has slightly changed the
behavior but resulted in significantly improved performance and more
readable code.
* Added `NoFinishHook` to aid composing of diff hooks.
## 1.1.0
* More generic lifetimes for `iter_changes` and `iter_inline_changes`.
* Added `iter_all_changes` shortcut as this is commonly useful.
* Added `iter_slices` to `DiffOp` to quickly get an iterator over the
encoded slices rather than individual items like `iter_changes` does.
* Added the `utils` module with various text diffing utilities.
* Added `TextDiffRemapper` which helps with working with the original, pre
`TextDiff` tokenization slices.
## 1.0.0
* Add `get_diff_ratio`.
* Add support for byte diffing and change the text interface to abstract
over `DiffableStr`.
* Restructured crate layout greatly. Text diffing is now on the crate root,
some functionality remains in the algorithms.
* The `Change` type now also works for non text diffs.
## 0.5.0
* Add `DiffOp::apply_to_hook` to apply a captured op to a diff hook.
* Added missing newline handling to the `Changes` type.
* Made unified diff support more flexible through the introduction of
the `UnifiedDiff` type.
* Fixed grouped diff operation to return an empty result if the diff
does not show any changes.
* Added inline diff highlighting support.
* Changed word splitting to split into words and whitespace.
* Added support for unicode based word splitting (`TextDiff::from_unicode_words`).
## 0.4.0
* Change `get_close_matches` to use Python's quick ratio optimization
and order lexicographically when tied.
## 0.3.0
* Added grapheme and character level diffing utilities.
* `DiffOp::as_tag_tuple` is now taking the argument by reference.
* Added `TextDiff::ratio`.
* Added `get_close_matches`.
## 0.2.0
* Fixed a bug in the patience algorithm causing it not not work.
## 0.1.0
* Initial release.

View file

@ -4,65 +4,99 @@ version = 3
[[package]]
name = "bstr"
version = "1.5.0"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5"
checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706"
dependencies = [
"memchr",
"once_cell",
"regex-automata",
"serde",
]
[[package]]
name = "console"
version = "0.15.7"
name = "bumpalo"
version = "3.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8"
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
[[package]]
name = "cfg-if"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
[[package]]
name = "console"
version = "0.15.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8"
dependencies = [
"encode_unicode",
"lazy_static",
"libc",
"once_cell",
"unicode-width",
"windows-sys",
]
[[package]]
name = "encode_unicode"
version = "0.3.6"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
[[package]]
name = "insta"
version = "1.31.0"
version = "1.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0770b0a3d4c70567f0d58331f3088b0e4c4f56c9b8d764efe654b4a5d46de3a"
checksum = "581d4e3314cae4536e5d22ffd23189d4a374696c5ef733eadafae0ed273fd303"
dependencies = [
"console",
"lazy_static",
"linked-hash-map",
"similar 2.2.1",
"similar",
"yaml-rust",
]
[[package]]
name = "itoa"
version = "0.4.8"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "js-sys"
version = "0.3.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c0b063578492ceec17683ef2f8c5e89121fbd0b172cbc280635ab7567db2738"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.147"
version = "0.2.175"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
[[package]]
name = "likewise"
version = "3.0.0"
dependencies = [
"bstr",
"console",
"insta",
"serde",
"serde_json",
"unicode-segmentation",
"web-time",
]
[[package]]
name = "linked-hash-map"
@ -71,61 +105,67 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "memchr"
version = "2.6.0"
name = "log"
version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c"
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
[[package]]
name = "memchr"
version = "2.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
[[package]]
name = "once_cell"
version = "1.19.0"
version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "proc-macro2"
version = "1.0.46"
version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.20"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6"
[[package]]
name = "ryu"
version = "1.0.15"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "serde"
version = "1.0.130"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.130"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
@ -134,38 +174,27 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.68"
version = "1.0.143"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8"
checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]
[[package]]
name = "similar"
version = "2.2.1"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf"
[[package]]
name = "similar"
version = "2.5.0"
dependencies = [
"bstr",
"console",
"insta",
"serde",
"serde_json",
"unicode-segmentation",
]
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
[[package]]
name = "syn"
version = "1.0.109"
version = "2.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
dependencies = [
"proc-macro2",
"quote",
@ -174,40 +203,109 @@ dependencies = [
[[package]]
name = "unicode-ident"
version = "1.0.11"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
[[package]]
name = "unicode-segmentation"
version = "1.10.1"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
name = "unicode-width"
version = "0.1.10"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c"
[[package]]
name = "wasm-bindgen"
version = "0.2.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e14915cadd45b529bb8d1f343c4ed0ac1de926144b746e2710f9cd05df6603b"
dependencies = [
"cfg-if",
"once_cell",
"wasm-bindgen-macro",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28d1ba982ca7923fd01448d5c30c6864d0a14109560296a162f80f305fb93bb"
dependencies = [
"bumpalo",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c3d463ae3eff775b0c45df9da45d68837702ac35af998361e2c84e7c5ec1b0d"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bb4ce89b08211f923caf51d527662b75bdc9c9c7aab40f86dcb9fb85ac552aa"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f143854a3b13752c6950862c906306adb27c7e839f7414cec8fea35beab624c1"
dependencies = [
"unicode-ident",
]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "windows-sys"
version = "0.45.0"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
@ -216,45 +314,51 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "yaml-rust"

View file

@ -1,16 +1,17 @@
[package]
name = "similar"
version = "2.7.0"
name = "likewise"
version = "3.0.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>",
]
edition = "2018"
rust-version = "1.60"
rust-version = "1.66"
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/*"]
@ -27,7 +28,7 @@ unicode = ["text", "unicode-segmentation", "bstr?/unicode", "bstr?/std"]
bytes = ["bstr", "text"]
[dev-dependencies]
insta = "1.10.0"
insta = "=1.21.0"
console = "0.15.0"
serde_json = "1.0.68"

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)
[![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)
> This crate is a fork of [similar](https://github.com/mitsuhiko/similar) library, which, as of 11/9/25, is rather inactive.
Similar is a dependency free crate for Rust that implements different diffing
[![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.66.0](https://img.shields.io/badge/rust-1.66%2B-orange.svg)](https://img.shields.io/badge/rust-1.65%2B-orange.svg)
[![Documentation](https://docs.rs/likewise/badge.svg)](https://docs.rs/likewise)
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 +1 @@
msrv = "1.60.0"
msrv = "1.66.0"

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

@ -1,7 +1,6 @@
---
source: src/text/inline.rs
expression: "&json"
---
[
{

View file

@ -1,7 +1,6 @@
---
source: src/text/mod.rs
expression: "&json"
---
[
{

View file

@ -1,7 +1,6 @@
---
source: src/text/mod.rs
expression: "&json"
---
[
{

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

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