• Stars
    star
    922
  • Rank 49,555 (Top 1.0 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A high level diffing library for rust based on diffs

Similar: A Diffing Library

Build Status Crates.io License rustc 1.41.0 Documentation

Similar is a dependency free crate for Rust that implements different diffing algorithms and high level interfaces for it. It is based on the pijul implementation of the Patience algorithm and inherits some ideas from there. It also incorporates the Myer's diff algorithm which was largely written by Brandon Williams. This library was built for the insta snapshot testing library.

use similar::{ChangeTag, TextDiff};

fn main() {
    let diff = TextDiff::from_lines(
        "Hello World\nThis is the second line.\nThis is the third.",
        "Hallo Welt\nThis is the second line.\nThis is life.\nMoar and more",
    );

    for change in diff.iter_all_changes() {
        let sign = match change.tag() {
            ChangeTag::Delete => "-",
            ChangeTag::Insert => "+",
            ChangeTag::Equal => " ",
        };
        print!("{}{}", sign, change);
    }
}

Screenshot

terminal highlighting

What's in the box?

  • Myer's diff
  • Patience diff
  • Hunt–McIlroy / Hunt–Szymanski LCS diff
  • Diffing on arbitrary comparable sequences
  • Line, word, character and grapheme level diffing
  • Text and Byte diffing
  • Unified diff generation

Related Projects

License and Links

More Repositories

1

rye

An Experimental Package Management Solution for Python
Rust
5,595
star
2

pipsi

pip script installer
Python
2,004
star
3

insta

A snapshot testing library for rust
Rust
1,594
star
4

pluginbase

A simple but flexible plugin system for Python.
Python
1,112
star
5

minijinja

MiniJinja is a powerful but minimal dependency template engine for Rust
Rust
864
star
6

flask-oauth

OAuth Support for Flask
Python
579
star
7

python-modernize

Modernizes Python code for eventual Python 3 migration. Build on top of 2to3
Python
531
star
8

self-replace

Utility library that helps to implement processes that replace themselves
Rust
483
star
9

idasen-control

Lets you control IKEA IDÃ…SEN desks from the command line.
JavaScript
423
star
10

dotfiles

My dotfiles (vim / bash etc.)
Vim Script
419
star
11

unp

Unpacks things.
Python
414
star
12

systemfd

Development helper utility for helping with auto reloading for projects supporting systemd socket activation
Rust
375
star
13

when

Timezones from the command line
Rust
361
star
14

better-panic

A python inspired panic handler for rust
Rust
340
star
15

platter

A useful helper for wheel deployments.
Python
332
star
16

teetty

A bit like tee, a bit like script, but all with a fake tty. Lets you remote control and watch a process
Rust
285
star
17

classy

A classy JavaScript class library
Python
267
star
18

flask-pastebin

Example pastebin with websockets, sqlalchemy, facebook connect and a bunch of other buzzwords
Python
264
star
19

deser

Experimental rust serialization library
Rust
256
star
20

python-geoip

GeoIP database access for Python under a BSD license.
Python
249
star
21

snaek

DEPRECATED: Being replaced with milksnake: https://github.com/getsentry/milksnake
Python
227
star
22

python-regex-scanner

Demo of how to use the underlying SRE engine to build a regex scanner
Python
217
star
23

lucumr

My personal website
CSS
211
star
24

timesched

Simple time scheduler application
JavaScript
211
star
25

rstblog

NIH site generator
Python
208
star
26

python-unio

Unbreaks Unicode on Python
Python
165
star
27

fragile

Utility wrapper to send non send types to other threads safely
Rust
150
star
28

procspawn

like thread::spawn but for processes
Rust
148
star
29

python-pbkdf2

Because pbkdf2 is awesome and bcrypt is overkill
Python
147
star
30

unbox

A work in progress command line utility to unpack various types of archives quickly.
Rust
137
star
31

listenfd

Helper crate to work with systemd/catflap socket activation
Rust
136
star
32

jinja2-htmlcompress

Compresses HTML in Jinja2 streams
Python
125
star
33

phpserialize

A PHP serializer implementation for Python
Python
122
star
34

webgl-meincraft

Minecraft engine thingy written in CoffeeScript and WebGL
JavaScript
107
star
35

similar-asserts

Provides assert_eq! like macros with colorized diff output
Rust
89
star
36

vim-jinja

Repository for Jinja support in vim.
Vim Script
86
star
37

jsonjinja

A Jinja2 inspired templating language for rendering JSON data on the server and client.
Python
81
star
38

bf3-aggregator

Sourcecode for the bf3 developer news aggregator.
Python
80
star
39

vim-python-combined

Fork of the python.vim by Dmitry Vasiliev and Neil Schemenauer for 2.x and 3.x.
Vim Script
76
star
40

unicode-nazi

Annoying helper module that finds unicode/bytestring comparisions
Python
71
star
41

multiversion

A hack that allows you to use different versions of the same library in the same Python process without clashes
Python
70
star
42

sha1-smol

Minimal and dependency free implementation of SHA1 for Rust
Rust
68
star
43

templatetk

My GSOC Project for Template Compilation
Python
67
star
44

solace

Non-plurk fork of Solace. Might eventually be merged back. Solace is a Stackoverflow inspired platform.
Python
64
star
45

badideas

Examples from my europython talk
Python
61
star
46

hq

jq but for html
Rust
60
star
47

speaklater

Lazy strings for Python
Python
59
star
48

elementtree-rust

Port of the Python element tree library to Rust
Rust
58
star
49

sqlalchemy-django-query

A Django like query object for SQLAlchemy
Python
50
star
50

fruity-vim-colorscheme

Fruity Colorscheme for Vim
Vim Script
47
star
51

probe

Probes remote websites
Python
46
star
52

fungiform

A form library for Python based on Zine's form system.
Python
44
star
53

serde-plain

A serde serializer that serializes a subset of types into plain strings
Rust
43
star
54

struckdown

An experimental markdown processing system
Rust
43
star
55

flask-feedback

Python
39
star
56

flatex-pdf-download

some code to toy with that can download flatex.at pdfs
Python
38
star
57

rust-execution-context

Implements a .NET inspired execution context for Rust
Rust
37
star
58

twig

a template engine for the chyrp blog engine.
PHP
36
star
59

rust-excessive-bools-lint

To save future generations from the "bools everywhere" antipattern.
Rust
35
star
60

unix-ipc

A super minimal wrapper around unix sockets for IPC.
Rust
35
star
61

dota2-demoinfo2

A version of Valve's Dota2 replay parser that also compiles on OS X (and hopefully Linux)
C++
34
star
62

frostbite2-stuff

Python libs for accessing Frostbite stuff
Python
33
star
63

jinja2-tmbundle

Editor support
33
star
64

ponyguruma

Oniguruma for Python
Python
32
star
65

flask-extension-wizard

Helper script to create Flask Extension Packages
Python
32
star
66

stack-tokens

Example implementation of stack tokens for Rust
Rust
31
star
67

proximity-tracing

Holds various things for proximity contact tracing.
Rust
31
star
68

tokio-unix-ipc

A super minimal wrapper around unix sockets for IPC on top of tokio.
Rust
31
star
69

python-inifile

Ini file library for Python
Python
31
star
70

cli-tools

Command line utilities
Python
31
star
71

zine

A blog
Python
30
star
72

webgame

Rust
27
star
73

super-secret-wsgi-replacement

My take on a WSGI replacement
26
star
74

rust-runas

Runs a command in an elevated context
Rust
26
star
75

mictoggle

Toggle microphone through hotkey
Swift
25
star
76

htmldiff

Diffs arbitrary HTML inline
Python
25
star
77

python-juggernaut

Python client library for juggernaut
Python
24
star
78

covidcotra

Some hackery for covid-19 contrac tracing
Rust
24
star
79

memo-map

A crate implementing a synchronized map for memoization
Rust
21
star
80

pyastutil

Various Python AST utilities
Python
19
star
81

clicolors-control

Rust library for controlling CLI colors
Rust
19
star
82

prettyprint

A prettyprinter for Python
Python
19
star
83

vim-rst

Restructured text support for vim
Vim Script
18
star
84

python-atomicfile

Helpers for atomic file operations
Python
18
star
85

flask-fungiform

Flask bridge to fungiform
Python
18
star
86

rust-eh

More error handling experiments in Rust.
Rust
18
star
87

rust-incidents

Even more error handling experiments in Rust.
Rust
17
star
88

aoc19

advent of code 2019 repo
Rust
16
star
89

vim-json

Simple JSON support for vim.
Vim Script
16
star
90

frameworkify

Making dylibs on OS X painless
Python
15
star
91

insta-cmd

CLI extension to insta
Rust
15
star
92

johanson

A hard fork of yajl for lightweight JSON parsing.
C
15
star
93

kickstarter-scraper

Scrapes kickstarter for some stats
Python
14
star
94

twitterlog

A Python log handler that logs to Twitter
Python
14
star
95

yamldb

A small wrapper around SQLite and YAML
Python
14
star
96

sandboxcraft

A small project that implements a voxel engine (hopefully)
C
14
star
97

rust-osascript

Rust wrapper around a bit of osascript
Rust
13
star
98

unicode-literals-pep

Not yet a proposed PEP about u'' in Python 3.3 and later
Python
12
star
99

small-ctor

Minimal, dependency free implementation of the ctor crate
Rust
11
star
100

libbattlelog

Dig around in battlelog
Python
11
star