Coder Social home page Coder Social logo

dissimilar's Introduction

Dissimilar: diff library with semantic cleanup

github crates.io docs.rs build status

This library is a port of the Diff component of Diff Match Patch to Rust. The diff implementation is based on Myers' diff algorithm but includes some semantic cleanups to increase human readability by factoring out commonalities which are likely to be coincidental.

Diff Match Patch was originally built in 2006 to power Google Docs.

[dependencies]
dissimilar = "1.0"

Compiler support: requires rustc 1.36+


Interface

Here is the entire API of the Rust implementation. It operates on borrowed strings and the return value of the diff algorithm is a vector of chunks pointing into slices of those input strings.

pub enum Chunk<'a> {
    Equal(&'a str),
    Delete(&'a str),
    Insert(&'a str),
}

pub fn diff(text1: &str, text2: &str) -> Vec<Chunk>;

License

The diff algorithm in this crate was ported to Rust using the Java and C++ implementations found at https://github.com/google/diff-match-patch as reference, and is made available here under the Apache License, Version 2.0 matching the license of the original. This entire project, including some parts unmodified from upstream and the Rust-specific modifications introduced in the course of porting the implementation, are distributed under this Apache license.

Intellectual property that is unique to the Rust implementation is additionally made available to you dually under the MIT license, if you prefer. This applies to all design choices and implementation choices not found in the upstream repo.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual Apache and MIT licensed, without any additional terms or conditions.

dissimilar's People

Contributors

dtolnay avatar upsuper avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.