{"id":17604270,"url":"https://github.com/dimakudosh/difflib","last_synced_at":"2025-07-14T18:33:03.343Z","repository":{"id":48384781,"uuid":"51599908","full_name":"DimaKudosh/difflib","owner":"DimaKudosh","description":"Port of Python's difflib library to Rust","archived":false,"fork":false,"pushed_at":"2021-07-28T21:05:38.000Z","size":54,"stargazers_count":48,"open_issues_count":3,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-07T18:14:33.053Z","etag":null,"topics":["difflib","python-difflib-library","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DimaKudosh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-12T16:14:45.000Z","updated_at":"2025-03-28T08:13:08.000Z","dependencies_parsed_at":"2022-09-26T16:50:22.759Z","dependency_job_id":null,"html_url":"https://github.com/DimaKudosh/difflib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimaKudosh%2Fdifflib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimaKudosh%2Fdifflib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimaKudosh%2Fdifflib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimaKudosh%2Fdifflib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DimaKudosh","download_url":"https://codeload.github.com/DimaKudosh/difflib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247704571,"owners_count":20982298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["difflib","python-difflib-library","rust"],"created_at":"2024-10-22T14:07:36.646Z","updated_at":"2025-04-07T18:14:53.717Z","avatar_url":"https://github.com/DimaKudosh.png","language":"Rust","readme":"# Difflib [![Build Status](https://travis-ci.org/DimaKudosh/difflib.svg?branch=master)](https://travis-ci.org/DimaKudosh/difflib)\n\nPort of Python's difflib library to Rust.\nIt's provide all necessary tools for comparing word sequences.\n\n## Installation\nSimply add difflib to your dependencies block in Cargo.toml\n\n```rust\n[dependencies]\ndifflib = \"0.4.0\"\n```\n\n## Documentation\nDocumentation is available at https://github.com/DimaKudosh/difflib/wiki\n\n## Example\n```rust\nextern crate difflib;\n\nuse difflib::differ::Differ;\nuse difflib::sequencematcher::SequenceMatcher;\n\nfn main() {\n    // unified_diff\n    let first_text = \"one two three four\".split(\" \").collect::\u003cVec\u003c\u0026str\u003e\u003e();\n    let second_text = \"zero one tree four\".split(\" \").collect::\u003cVec\u003c\u0026str\u003e\u003e();\n    let diff = difflib::unified_diff(\n        \u0026first_text,\n        \u0026second_text,\n        \"Original\",\n        \"Current\",\n        \"2005-01-26 23:30:50\",\n        \"2010-04-02 10:20:52\",\n        3,\n    );\n    for line in \u0026diff {\n        println!(\"{:?}\", line);\n    }\n\n    //context_diff\n    let diff = difflib::context_diff(\n        \u0026first_text,\n        \u0026second_text,\n        \"Original\",\n        \"Current\",\n        \"2005-01-26 23:30:50\",\n        \"2010-04-02 10:20:52\",\n        3,\n    );\n    for line in \u0026diff {\n        println!(\"{:?}\", line);\n    }\n\n    //get_close_matches\n    let words = vec![\"ape\", \"apple\", \"peach\", \"puppy\"];\n    let result = difflib::get_close_matches(\"appel\", words, 3, 0.6);\n    println!(\"{:?}\", result);\n\n    //Differ examples\n    let differ = Differ::new();\n    let diff = differ.compare(\u0026first_text, \u0026second_text);\n    for line in \u0026diff {\n        println!(\"{:?}\", line);\n    }\n\n    //SequenceMatcher examples\n    let mut matcher = SequenceMatcher::new(\"one two three four\", \"zero one tree four\");\n    let m = matcher.find_longest_match(0, 18, 0, 18);\n    println!(\"{:?}\", m);\n    let all_matches = matcher.get_matching_blocks();\n    println!(\"{:?}\", all_matches);\n    let opcode = matcher.get_opcodes();\n    println!(\"{:?}\", opcode);\n    let grouped_opcodes = matcher.get_grouped_opcodes(2);\n    println!(\"{:?}\", grouped_opcodes);\n    let ratio = matcher.ratio();\n    println!(\"{:?}\", ratio);\n    matcher.set_seqs(\"aaaaa\", \"aaaab\");\n    println!(\"{:?}\", matcher.ratio());\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimakudosh%2Fdifflib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimakudosh%2Fdifflib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimakudosh%2Fdifflib/lists"}